Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error running tests with Detox in Expo React Native project

When I try to run my tests using detox in a React Native Expo project, I get the following error:

detox[18834] WARN:  [Client.js/PENDING_REQUESTS] App has not responded to the network requests below:
  (id = -1000) isReady: {}

That might be the reason why the test "Login workflow should have login screen" has timed out.

detox[18834] INFO:  Login workflow: should have login screen [FAIL]

 FAIL  e2e/firstTest.e2e.js (137.697 s)
  Login workflow
    ✕ should have login screen (120015 ms)

  ● Login workflow › should have login screen

    thrown: "Exceeded timeout of 120000 ms for a hook.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

       7 |   });
       8 |
    >  9 |   it('should have login screen', async () => {
         |   ^
      10 |     await expect(element(by.id('loginFormTitle'))).toBeVisible()
      11 |   });
      12 |

      at firstTest.e2e.js:9:3
      at Object.<anonymous> (firstTest.e2e.js:8:1)

detox[18833] ERROR: [cli.js] Error: Command failed: node_modules/.bin/jest --config e2e/config.json '--testNamePattern=^((?!:android:).)*$' --maxWorkers 1 e2e

I am running iPhone 11 Pro simulator, and the expo app is already running in a separate server. I also have a Exponent.app in my /bin folder, which I downloaded from Expo's website. The logic in my test case doesn't require any timeout and it involves just a simple login screen.

Any solution for this error?

like image 369
Sabbir Ahmed Avatar asked Oct 23 '25 23:10

Sabbir Ahmed


1 Answers

I had a similar issue using the latest version of Expo (v39).

It seems like the issue is that Detox waits for an app is ready event before running the tests, but this doesn’t get triggered with the most recent versions of the Expo SDK.

The solution I ended up with was to create a standalone build of the app and run Detox against that.

My .detoxrc.json looks like:

{
  ...,
  "configurations": {
    "ios": {
      "type": "ios.simulator",
      "build": "expo build:ios -t simulator",
      "binaryPath": "bin/myapp.app",                                                                                                            
    }
  }
}
like image 167
Felix Clack Avatar answered Oct 25 '25 18:10

Felix Clack



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!