Jesse Hill
Jesse Hill

Reputation: 1994

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?

Upvotes: 1

Views: 2691

Answers (2)

Slav Kurochkin
Slav Kurochkin

Reputation: 424

Looks like you don't have detox .init method hooked to your tests. Make sure you have e2e/init.js and there you would need to add

before(async () => {
     await detox.init(config);
});

Also make sure you call this file in config.json (might be wrong here, I'm using Mocha and mocha.opts instead there)

Upvotes: 0

Jesse Hill
Jesse Hill

Reputation: 1994

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.

Upvotes: 7

Related Questions