Detox: Jest CLI options such as --onlyChanged don’t work
Description
Jest CLI options such as --onlyChanged
and --watch
don’t work because Detox always passes the e2e
directory.
✓ I have tested this issue on the latest Detox release and it still reproduces.
Reproduction
- Clone DetoxTemplate.
- Follow the instructions there.
npm install detox@18.19.0 --save-dev
npm run test:ios-debug -- --onlyChanged
Expected behavior
Jest understands the --onlyChanged
option and only runs tests which have changed.
Suggested solution
Detox explicitly passes the e2e
directory when invoking Jest, for example, jest --config e2e/config.json e2e
. When specifying both --onlyChanged
and e2e
, Jest gives preference to e2e
and runs all tests.
However, specifying e2e
is not really necessary because Jest defaults to running all tests matching testMatch
in the rootDir
. For example, jest --config e2e/config.json
also executes all tests.
Without e2e
, options such as --onlyChanged
work. For example, you can invoke Jest manually with:
$ DETOX_CONFIGURATION="ios.sim.debug" npx jest --config e2e/config.json --onlyChanged
Then, Jest properly exits with “No tests found related to files changed since last commit.”
Environment
- Detox: 18.19.0
- React Native: 0.64.4
- Node: 14.17.3
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (9 by maintainers)
Thanks! I can confirm that
--onlyChanged
now works properly with Detox v20.This will be a breaking change. I added it to the plan to Detox 20: https://github.com/wix/Detox/discussions/2838 Also, related issue: https://github.com/wix/Detox/issues/3076