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
Running the dev script concurrently with the Jest test script causes Jest to re-run the tests on page compilation #32650
Comments
Appreciate the research! I opened #32659 that should fix this. For now, simply adding this to your jest config is enough: watchPathIgnorePatterns: [
'/.next/',
], |
`jest --watch` looks for [changes in dotfiles and folders by default](jestjs/jest#10075), which resulted in the tests being re-run when navigating between pages with `next dev`. Fixes #32650 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
Thanks, I actually used |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
`jest --watch` looks for [changes in dotfiles and folders by default](jestjs/jest#10075), which resulted in the tests being re-run when navigating between pages with `next dev`. Fixes vercel#32650 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
What version of Next.js are you using?
12.0.4
What version of Node.js are you using?
14.18.2
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
Vercel
Describe the Bug
jest --watch
re-runs the test suites every time the dev server compiles a page. This bug is present on both the babel and swc versions of the jest config.I found out that the Jest watcher is watching the
.next/
folder. It used to ignore dot files and folders but that behaviour was changed last year (jestjs/jest#10075). It is now necessary to specify the dot folder inwatchPathIgnorePatterns
. I created a PR with Jest to change the documentation: jestjs/jest#12161Expected Behavior
I expect Jest in watch mode to only re-run the test suites when source files or test files have changed, not when the dev server writes to
.next/
.To Reproduce
Step 1: Set up a project with any of the Jest configurations (Babel or Swc). The project needs to have several pages to be able to navigate between them.
Step 2: run
yarn dev
in a terminal. In another terminal, runyarn test
. The scripts are standard:Step 3: in the jest terminal, press A to run all tests.
My original case was to add a page and a related test file. But running all tests requires less work to show the same result.
Step 4: In the browser, navigate between pages.
Result:
The text was updated successfully, but these errors were encountered: