LLimrun

Run Detox tests

Your Detox test files stay the same. Jest and the Detox tester run where they run today, on your laptop or a Linux CI runner, and the app runs on a Limrun iOS simulator. The @limrun/detox package supplies a Detox device driver for the remote simulator and helpers that wire the session together.

Detox on Limrun covers iOS simulator instances.

Before you start

How the integration works

Detox has three parts: the tester (Jest plus Detox, on your machine), a mediator server (detox run-server), and a native client that Detox loads into the app process. Limrun splits them across the network:

Configure Detox

Point a Detox device at the Limrun driver and read the mediator URL and session ID from the environment, which runDetoxTest sets:

.detoxrc.cjs
/** @type {Detox.DetoxConfig} */
module.exports = {
  testRunner: {
    args: { config: 'e2e/jest.config.cjs' },
    jest: { setupTimeout: 120000 },
  },
  session: {
    server: process.env.DETOX_SERVER || 'ws://localhost:8099',
    sessionId: process.env.DETOX_SESSION_ID || 'limrun-detox',
  },
  behavior: {
    init: { reinstallApp: false, exposeGlobals: true },
    cleanup: { shutdownDevice: false },
  },
  devices: {
    limrun: {
      type: '@limrun/detox/driver',
      device: { id: process.env.LIMRUN_IOS_ID || 'limrun-remote-ios' },
    },
  },
  configurations: {
    'ios.limrun': { device: 'limrun' },
  },
};

reinstallApp: false and shutdownDevice: false matter: the app is already on the instance, and the instance's lifetime belongs to your script, not to Detox.

Run a test

The script below creates an instance with Expo Go installed, prepares the mediator and tunnel, runs detox test, and cleans up:

run-detox.ts
import { Ios, Limrun } from '@limrun/api';
import { prepareDetoxRun, runDetoxTest } from '@limrun/detox';

const limrun = new Limrun({ apiKey: process.env.LIM_API_KEY });

const instance = await limrun.iosInstances.create({
  wait: true,
  spec: {
    initialAssets: [{ kind: 'App', source: 'AssetName', assetName: 'appstore/Expo-Go-54.0.6.tar.gz' }],
  },
});
const client = await Ios.createInstanceClient({
  apiUrl: instance.status.apiUrl!,
  token: instance.status.token!,
});

const prepared = await prepareDetoxRun({ client });
try {
  const result = await runDetoxTest({
    configPath: './.detoxrc.cjs',
    configuration: 'ios.limrun',
    sessionId: prepared.sessionId,
    serverUrl: prepared.detoxServerUrl,
    iosId: instance.metadata.id,
    iosApiUrl: instance.status.apiUrl,
    iosToken: instance.status.token,
    artifactDirectory: prepared.artifactDirectory,
    extraEnv: {
      EXPO_URL: process.env.EXPO_URL!,
      LIMRUN_DETOX_SERVER_URL: prepared.remoteDetoxServerUrl,
      DETOX_VERSION: prepared.version,
    },
  });
  if (result.code !== 0) throw new Error(`Detox exited with ${result.code}`);
} finally {
  await prepared.cleanup();
  client.disconnect();
  await limrun.iosInstances.delete(instance.metadata.id);
}

prepareDetoxRun reads the Detox version from the detox package installed in the working directory unless you pass version. runDetoxTest runs your local node_modules/.bin/detox test and writes its output to detox.stdout.log, detox.stderr.log, and detox.summary.json in the artifact directory, with screenshots under detox-artifacts/.

The app launches from the test's setup, so Detox's native client connects before the first assertion. For Expo Go, launchExpoGoDetoxAppFromEnv launches Expo Go with the Detox runtime, opens EXPO_URL, and accepts Expo Go's open prompt:

e2e/app.test.js
const { launchExpoGoDetoxAppFromEnv } = require('@limrun/detox');

describe('app', () => {
  beforeAll(async () => {
    process.env.DETOX_EXPECTED_TEXT = 'My App Home';
    await launchExpoGoDetoxAppFromEnv();
  }, 120000);

  it('shows the home screen', async () => {
    await expect(element(by.text('My App Home'))).toBeVisible();
  });
});

DETOX_EXPECTED_TEXT (or DETOX_EXPECTED_ELEMENT_ID) is what the helper waits for before it returns, so set it to something on your first screen.

For your own build instead of Expo Go, launch it with the Detox runtime from the test's setup. runDetoxTest passes the instance URL, token, and session ID to Jest as LIMRUN_IOS_API_URL, LIMRUN_IOS_TOKEN, and DETOX_SESSION_ID; the mediator URL and version come from the extraEnv above:

e2e/app.test.js
const { Ios } = require('@limrun/api');

beforeAll(async () => {
  const client = await Ios.createInstanceClient({
    apiUrl: process.env.LIMRUN_IOS_API_URL,
    token: process.env.LIMRUN_IOS_TOKEN,
  });
  await client.launchApp('com.example.myapp', {
    mode: 'RelaunchIfRunning',
    runtime: {
      kind: 'detox',
      serverUrl: process.env.LIMRUN_DETOX_SERVER_URL,
      sessionId: process.env.DETOX_SESSION_ID,
      version: process.env.DETOX_VERSION,
    },
  });
  client.disconnect();
}, 120000);

The CLI exposes the same launch as lim ios launch-app <bundle-id> --runtime detox with --detox-server-url, --detox-session-id, and --detox-version.

The runnable example, which drives a sample Expo app through taps, text entry, navigation, and screenshots, is at typescript-sdk/examples/detox-ios.

Run from a Linux CI runner

No macOS host is needed. The CI job needs Node, your project's dependencies including detox and @limrun/detox, and LIM_API_KEY, plus anything your app reads at launch, such as EXPO_URL:

.github/workflows/detox-ios.yml
name: Detox iOS
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: '22'

      - run: npm ci

      - name: Run Detox on Limrun
        env:
          LIM_API_KEY: ${{ secrets.LIM_API_KEY }}
        run: npx tsx run-detox.ts

Next steps

smartphone

Run a simulator

Create, configure, and drive iOS simulators.

network

Connect to local services

Serve an Expo project or a mock backend from your machine to the simulator.

flask-conical

Maestro

Run Maestro flows against a cloud iOS simulator.

flask-conical

Appium

Run Appium suites on iOS simulators and Android emulators.