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

Watch mode "f" command does not rerun failed tests #3687

Open
eloiqs opened this issue Jun 28, 2023 · 3 comments · May be fixed by #3773
Open

Watch mode "f" command does not rerun failed tests #3687

eloiqs opened this issue Jun 28, 2023 · 3 comments · May be fixed by #3773
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) pr welcome

Comments

@eloiqs
Copy link

eloiqs commented Jun 28, 2023

Describe the bug

When in watch mode and pressing "f" to rerun failed tests, "rerun failed" is printed and failed tests are reran but the watcher does not remember that I pressed f on file changes. I would expect a file change to rerun only the failed tests as long as I have selected the "f" command like in Jest.

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-5nbzar?file=test%2Fsuite.test.ts&issueNumber=3687&issueRepo=vitest-dev/vitest

  1. wait for the tests to run
  2. in watch console press "f"
  3. notice "rerun failed" is printed and the whole suite containing the failed test reruns
    image
  4. trigger a file change in basic.test.js
  5. notice that only basic.test.js was reran, disregarding that I was in failure only mode.
    image

I expected the watcher to stay in "rerun failed" mode, rerun suite.test.js, and behave in that way until I exit "rerun failed" mode by pressing "a" or "r".

System Info

The stackblitz env is this 

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.20.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.6.3 - /usr/local/bin/pnpm
  npmPackages:
    @vitest/ui: latest => 0.32.2 
    vite: latest => 4.3.9 
    vitest: latest => 0.32.2 

But I have the same problem locally on

  System:
    OS: macOS 13.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 3.76 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.10.0 - ~/.nvm/versions/node/v16.10.0/bin/node
    npm: 8.18.0 - ~/.nvm/versions/node/v16.10.0/bin/npm
  Browsers:
    Brave Browser: 113.1.51.110
    Chrome: 109.0.5414.87
    Edge: 114.0.1823.51
    Firefox: 112.0.1
    Safari: 16.4
  npmPackages:
    @vitejs/plugin-basic-ssl: ^1.0.1 => 1.0.1
    @vitejs/plugin-react: ^3.1.0 => 3.1.0
    @vitest/coverage-c8: ^0.32.2 => 0.32.2
    @vitest/ui: ^0.32.2 => 0.32.2
    vite: ^4.1.1 => 4.1.1
    vitest: ^0.32.2 => 0.32.2


### Used Package Manager

npm

### Validations

- [X] Follow our [Code of Conduct](https://github.com/vitest-dev/vitest/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vitest-dev/vitest/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vitest.dev/guide/).
- [X] Check that there isn't [already an issue](https://github.com/vitest-dev/vitest/issues) that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitest-dev/vitest/discussions) or join our [Discord Chat Server](https://chat.vitest.dev).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
@stackblitz
Copy link

stackblitz bot commented Jun 28, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@AriPerkkio
Copy link
Member

The issue title is a bit misleading since failed tests are indeed run when f is pressed. But I think the bugs here are:

  • f runs all test cases of the test files that contained failures, not just the failed test cases
  • f filter does not persist when other files are changed

For the second part I think we need to check for the filter around here:

// A file that does not match the current filename pattern was changed

@eloiqs
Copy link
Author

eloiqs commented Jul 4, 2023

The issue title is a bit misleading since failed tests are indeed run when f is pressed

Yes, sorry, I think I was confused because the output contained "rerun failed".

f filter does not persist when other files are changed

Yes, I think that this is the behavior that was most unexpected on my end. I would have liked the cli to keep running failed tests when triggering a file change.

@btea btea linked a pull request Jul 15, 2023 that will close this issue
@sheremet-va sheremet-va added p3-minor-bug An edge case that only affects very specific usage (priority) and removed bug labels Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) pr welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants