yaron1m / expo-detox-typescript-example

Sample Expo app with e2e tests using detox, jest and typescript
MIT License
90 stars 9 forks source link

Tests failing due to app not reloading #3

Open roelandvanbatenburg opened 4 years ago

roelandvanbatenburg commented 4 years ago

When I run the tests it seems that the app is not reloaded and thus the tests are failing. The Simulator keeps showing Expo's Projects tab I know that detox is no longer supporting expo, but I hope the community can help me out.

➜  expo-detox-typescript-example git:(master) npm run e2e

> @ e2e /Users/roelandvanbatenburg/development/Artisans/expo-detox-typescript-example
> detox test --configuration ios.sim

detox[15333] INFO:  [test.js] configuration="ios.sim" artifactsLocation="artifacts/ios.sim.2019-09-24 07-39-44Z" recordLogs="none" takeScreenshots="manual" recordVideos="none" node_modules/.bin/jest --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)*$'
detox[15334] INFO:  [DetoxServer.js] server listening on localhost:63920...
detox[15334] INFO:  [AppleSimUtils.js] host.exp.Exponent launched. The stdout and stderr logs were recreated, you can watch them with:
        tail -F /Users/roelandvanbatenburg/Library/Developer/CoreSimulator/Devices/0E4C71F2-921B-47D9-82F2-F189637D8E32/data/tmp/detox.last_launch_app_log.{out,err}
 FAIL  e2e/firstTest.spec.ts (121.691s)
  Authentication tests
    ✕ should change the text when buttons are pressed (443ms)

  ● Authentication tests › should change the text when buttons are pressed

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

      at mapper (../node_modules/jest-jasmine2/build/queueRunner.js:25:45)

  ● Authentication tests › should change the text when buttons are pressed

    ReferenceError: device is not defined

      at Object.reloadApp (../node_modules/detox-expo-helpers/index.js:68:3)

  ● Authentication tests › should change the text when buttons are pressed

    TypeError: Cannot read property 'id' of undefined

      at Object.get (../node_modules/detox/src/exportWrapper.js:43:48)
      at Object.<anonymous> (firstTest.spec.ts:55:88)
      at step (firstTest.spec.ts:32:23)
      at Object.next (firstTest.spec.ts:13:53)
      at firstTest.spec.ts:7:71
      at Object.<anonymous>.__awaiter (firstTest.spec.ts:3:12)
      at Object.<anonymous> (firstTest.spec.ts:52:80)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        121.799s, estimated 122s
Ran all test suites with tests matching "^((?!:android:).)*$".
detox[15333] ERROR: [cli.js] Error: Command failed: node_modules/.bin/jest --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)*$'

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ e2e: `detox test --configuration ios.sim`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/roelandvanbatenburg/.npm/_logs/2019-09-24T07_41_47_182Z-debug.log
beaur commented 4 years ago

I think this is due to using version 12.3.0 of detox which is quite old and does not support iOS 13 / Xcode 11.

The fix would be to use the latest version of detox, however this has another issue with the live reloading that expo uses.

The only fix I have found for that, is to patch the detox library as per the patch here: https://github.com/wix/Detox/issues/1422#issuecomment-516033748

roelandvanbatenburg commented 4 years ago

Thanks, I'm looking into Kobiton/Appium right now, I'll try your fix when I can.