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

Jest CLI options such as --onlyChanged don’t work #2901

Closed
sonicdoe opened this issue Jul 16, 2021 · 22 comments
Closed

Jest CLI options such as --onlyChanged don’t work #2901

sonicdoe opened this issue Jul 16, 2021 · 22 comments

Comments

@sonicdoe
Copy link
Contributor

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

  1. Clone DetoxTemplate.
  2. Follow the instructions there.
  3. npm install detox@18.19.0 --save-dev
  4. 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
@noomorph
Copy link
Collaborator

noomorph commented Jul 16, 2021

@d4vidi, shall we add one more skipLegacySpecsInjection? 😆
P. S. Actually I am not that much kidding, the OP pointed at one more imprudent design solution of ours, circa 2017.

@noomorph
Copy link
Collaborator

noomorph commented Jul 16, 2021

@sonicdoe, may I suggest adding specs: ' ' to your Detox config? Make sure it has whitespace inside.

diff --git a/detox/test/e2e/detox.config.js b/detox/test/e2e/detox.config.js
index 215c13a0..44e0fafa 100644
--- a/detox/test/e2e/detox.config.js
+++ b/detox/test/e2e/detox.config.js
@@ -8,7 +8,7 @@ const launchArgs = {
 const config = {
   testRunner: 'nyc jest',
   runnerConfig: 'e2e/config.js',
-  specs: 'e2e/*.test.js',
+  specs: ' ',
   skipLegacyWorkersInjection: true,

   behavior: {

@sonicdoe
Copy link
Contributor Author

Thanks, that works 👍 By the way, this specs option doesn’t seem to be documented in the configuration options.

@stale
Copy link

stale bot commented Aug 18, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

@stale stale bot added the 🏚 stale label Aug 18, 2021
@sonicdoe
Copy link
Contributor Author

This issue is still present in Detox v18.20.2.

@stale stale bot removed the 🏚 stale label Aug 19, 2021
@d4vidi
Copy link
Collaborator

d4vidi commented Aug 29, 2021

@noomorph something to address this week, maybe?

@stale
Copy link

stale bot commented Sep 28, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

@stale stale bot added the 🏚 stale label Sep 28, 2021
@sonicdoe
Copy link
Contributor Author

This issue is still present in Detox v18.22.0.

@stale stale bot removed the 🏚 stale label Sep 30, 2021
@d4vidi d4vidi modified the milestones: Q2/2021 (codename Devox), Q4 Bugathon Oct 3, 2021
@stale
Copy link

stale bot commented Nov 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

@stale stale bot added the 🏚 stale label Nov 2, 2021
@sonicdoe
Copy link
Contributor Author

sonicdoe commented Nov 3, 2021

I haven’t tested it again, but looking at the changelog, I assume this is still present in the latest version.

@noomorph
Copy link
Collaborator

This will be a breaking change.
I added it to the plan to Detox 20: #2838
Also, related issue: #3076

@d4vidi d4vidi modified the milestones: Q4/2021 Bugathon, Detox20 Apr 13, 2022
@d4vidi d4vidi removed this from the Detox20 milestone May 17, 2022
@stale
Copy link

stale bot commented Jun 18, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

@stale stale bot added the 🏚 stale label Jun 18, 2022
@sonicdoe
Copy link
Contributor Author

I haven’t tested it again, but I assume this issue is still relevant.

@stale stale bot removed the 🏚 stale label Jun 20, 2022
@stale
Copy link

stale bot commented Jul 25, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

@stale stale bot added the 🏚 stale label Jul 25, 2022
@sonicdoe
Copy link
Contributor Author

I haven’t tested it again, but I assume this issue is still relevant.

@stale stale bot removed the 🏚 stale label Jul 25, 2022
@stale
Copy link

stale bot commented Sep 8, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

@stale stale bot added the 🏚 stale label Sep 8, 2022
@sonicdoe
Copy link
Contributor Author

sonicdoe commented Sep 9, 2022

I haven’t tested it again, but I assume this issue is still relevant.

@d4vidi
Copy link
Collaborator

d4vidi commented Sep 13, 2022

@noomorph wouldn't it be better off if the issue is merged with Detox 20?
Also, is platform: non-specific better than not specifying the platform altogehter?

@noomorph
Copy link
Collaborator

I think this issue is no longer relevant for Detox 20.

Please create a new one if something does not work.
We don't use specs anymore.

@sonicdoe
Copy link
Contributor Author

Thanks! I can confirm that --onlyChanged now works properly with Detox v20.

@noomorph
Copy link
Collaborator

@sonicdoe let me know if you experience issues in -R, --retries mode. I think this is likely, so if it confirms, I'll fix it.

@sonicdoe
Copy link
Contributor Author

As far as I can tell, --onlyChanged works fine with --retries; it respawns jest with --onlyChanged and the failed test file. If there are no changed files, it immediately exits and doesn’t retry anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants