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

Fix --onlyfailures flag to work in non-watch mode #10678

Merged
merged 1 commit into from Oct 23, 2020

Conversation

victorphoenix3
Copy link
Contributor

Fixes #6470 .
Previously, upon passing the --onlyFailures flag in non-watch mode, all the tests were run instead of just the failed tests.
This PR fixes the bug. Now, the --onlyFailures flag will work as expected in non-watch mode.

@victorphoenix3
Copy link
Contributor Author

This is ready for review @SimenB . Thanks!

@victorphoenix3 victorphoenix3 changed the title Make --onlyfailures flag work in non-watch mode Fix --onlyfailures flag to work in non-watch mode Oct 22, 2020
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This looks really good.

The only thing I think is missing is an integration test. A test that:

  • runs some tests where one fail (but one or more passes)
  • runs jest again with --onlyFailures and verify that only one test triggered (and it failed)
  • make a change that fixes said test
  • runs jest again with --onlyFailures passed - still only that test should run, but this this it should pass
  • run jest yet again with --onlyFailures passed and it should run no tests printing the warning

packages/jest-core/src/runJest.ts Outdated Show resolved Hide resolved
packages/jest-test-sequencer/src/index.ts Outdated Show resolved Hide resolved
packages/jest-core/src/getNoTestFoundFailed.ts Outdated Show resolved Hide resolved
newOptions.onlyChanged = newOptions.watch;
newOptions.onlyFailures = newOptions.watch;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a change in behavior for the watch flag, but I like it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, coming back to this, I don't 😅 If I run in watch mode I want to run all tests I specify, not just the ones that failed last time (unless I opt in to this behavior)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I said I liked it, what I thought at the time this did was, that in addition to running the specified files, we'll run any failing tests. But that's not what this does

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no way to opt out of this behaviour without using the command line Press f as far as I can tell. It's broken running jest in watch mode in webstorm as you cannot interact with the CLI. This behaviour is a pain.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@domarmstrong reverted in #10692, will make a new release once #10690 is solved

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant thanks for the info 👍

@victorphoenix3
Copy link
Contributor Author

@SimenB I've added the integration test

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is a great contribution 👍

@gsouf
Copy link

gsouf commented Nov 26, 2020

@SimenB has this been released in stable release? Cannot get it to work

@SimenB
Copy link
Member

SimenB commented Nov 26, 2020

It was released in 26.6.1. If it doesn't work, please open up a new issue

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Passing --onlyFailures doesn't run failed tests only
5 participants