Search code examples
react-nativereact-native-iosdetox

The simulator doesn't open when running detox test on iOS


When I try to run detox test the simulator doesn't appear to open and the tests just time out.

I confirmed that my setup is correct and also tried this to make sure my simulator can be launched from the terminal and that the device types in my detox config are correct.

The errors I receive are below.

Timeout - Async callback was not invoked within the 300000ms timeout specified by jest.setTimeout.
Error: Timeout - Async callback was not invoked within the 300000ms timeout specified by jest.setTimeout.

and

DetoxRuntimeError: Detox instance has not been initialized

HINT: There was an error on attempt to call detox.init()

DetoxRuntimeError: Aborted detox.init() execution, and now running detox.cleanup()

HINT: Most likely, your test runner is tearing down the suite due to the timeout error

Here is my config with the app names removed for privacy reasons.

"ios.sim.debug": {
    "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/example.app",
    "build": "xcodebuild -workspace ios/example.xcworkspace -scheme example -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
    "type": "ios.simulator",
    "device": {
        "type": "iPhone 11 Pro"
    }
},

How can I debug this?


Solution

  • I found that starting with Xcode 9 detox runs the iOS simulator in headless mode. If you are running the tests and then use Spotlight to pull up the simulator and hit enter then it will bring all of the simulators detox has opened to the front.

    enter image description here

    I discovered this from this comment.

    I also figured out that the reason my tests were timing out is that there was a prompt that the user needed to respond to which was blocking the detox tests from progressing.