Detox failing to run on Bitrise, fine with local setup


We’re trying to setup detox to pass our first E2E tests, following these steps:

One difference: we’re running the tests with jest.

Everything seems to be fine locally (I haven’t managed to get it fail even once, and we’ve tested it on different macs!), but on bitrise, jest (that we use to run detox tests) is timing out, then reporting this problem:

ReferenceError: device is not defined
  at Object._callee3$ (jest.setup.js:15:1)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:63:29)
  at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:337:12)
  at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:96:13)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:63:29)
  at invoke (node_modules/regenerator-runtime/runtime.js:139:12)
  at node_modules/regenerator-runtime/runtime.js:184:1
  at tryCallTwo (node_modules/promise/lib/core.js:45:1)
  at doResolve (node_modules/promise/lib/core.js:200:9)
  at new Promise (node_modules/promise/lib/core.js:66:1)
  at callInvokeWithMethodAndArg (node_modules/regenerator-runtime/runtime.js:183:8)
  at AsyncIterator.enqueue [as _invoke] (node_modules/regenerator-runtime/runtime.js:206:1)
  at AsyncIterator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:96:13)
  at Object.<anonymous>.runtime.async (node_modules/regenerator-runtime/runtime.js:226:6)

On example build:

Should I also include our bitrise.yml?
I’ve even included a step to manually start the simulator, without any luck.

Is there anyone else experiencing a similar issue?

  at Object._callee3 (jest.setup.js:14:58)

Hey @dropsmark

Did you try this solution? And I also recommend local debugging to discover the source of issue. This recommends another further option to override the default time interval.

Hi !

Thanks for the suggestion, but we’re using async functions everywhere, and setting timeout like this:

I haven’t thought of local debugging, but I’ll try that now, thank you!
Hopefully I’ll be able to reproduce the issue that way.


Managed to reproduce it locally, yay!
I’ll update this issue if I find out the root cause.

We are installing the NodeJS this way, if it helps you figure out :slight_smile:

I was wrong - I couldn’t reproduce the issue locally, it passes (after a while).
What should by the next step I should take if I have an issue where it runs locally (with bitrise.yml) and it doesn’t on the CI server?

Is your node js the latest in local? And did you tried the local test inside docker?


Managed to find the issue, thank you!

It seems like when jest’s setup was executed, in all of our local enviornment, the detox module was already loaded, but not on the CI.

removed the part we’ve called detox related stuff from jest’s setup.js

Thank you for the support!


I’m glad to hear that, thank you for sharing the details of the solution :slight_smile:

1 Like