Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to setup Detox in an Expo project #1159

Closed
dolsem opened this issue Feb 16, 2019 · 1 comment
Closed

Unable to setup Detox in an Expo project #1159

dolsem opened this issue Feb 16, 2019 · 1 comment

Comments

@dolsem
Copy link

dolsem commented Feb 16, 2019

Description

I am trying to setup Detox in an Expo project. Both Jest and Mocha fail with 'cannot find module' error. Jest complains about not finding fs-extra, Mocha about source-map-support. Seems like the issue is with test runners not knowing where to search for Detox dependencies.

Steps to Reproduce

  1. Follow Detox guide to install all dependencies
  2. Generate e2e folder with detox init -r jest
  3. Substitute device.reloadReactNative() with reloadApp() from detox-expo-helpers
  4. Run detox test -c ios:sim

Detox, Node, Device, Xcode and macOS Versions

  • Detox: 10.0.7
  • React Native: 0.57.7
  • Expo: 31.0.5
  • Node: 9.11.2
  • Device: iOS Simulator
  • Xcode: 10.1 beta
  • macOS: 10.13.6

Device and verbose Detox logs

configuration="ios.sim" loglevel="verbose" artifactsLocation="artifacts/ios.sim.2019-02-16 06-51-34Z" node_modules/.bin/jest "e2e" --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)*$' 
● Deprecation Warning:

  Option "setupTestFrameworkScriptFile" was replaced by configuration "setupFilesAfterEnv", which supports multiple paths.

  Please update your configuration.

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html

 FAIL  ../../../mnt/Documents/Projects/ExpoApp/e2e/firstTest.spec.js
  ● Test suite failed to run

    Cannot find module 'fs-extra' from 'logger.js'

    However, Jest was able to find:
    	'utils/logger.js'

    You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].

    See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

    However, Jest was able to find:
    	'./Detox.js'

    You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].

    See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

      at Resolver.resolveModule (../../../../../../Users/dols3m/va/node_modules/jest/node_modules/jest-resolve/build/index.js:203:17)
      at Object.<anonymous> (../node_modules/detox/src/utils/logger.js:2:12)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.945s
Ran all test suites matching /e2e/i with tests matching "^((?!:android:).)*$".
child_process.js:615
    throw err;
    ^

Error: Command failed: node_modules/.bin/jest "e2e" --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)*$' 
    at checkExecSyncError (child_process.js:575:11)
    at Object.execSync (child_process.js:612:13)
    at runJest (/Users/dols3m/va/node_modules/detox/local-cli/detox-test.js:166:6)
    at run (/Users/dols3m/va/node_modules/detox/local-cli/detox-test.js:86:7)
    at Object.<anonymous> (/Users/dols3m/va/node_modules/detox/local-cli/detox-test.js:229:1)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
@dolsem
Copy link
Author

dolsem commented Feb 16, 2019

Turns out the problem was caused by using symbolic links to project files instead of real files. Apparently neither Jest nor Mocha support that.

@dolsem dolsem closed this as completed Feb 16, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant