From 6ffa2baa4d0392cddc462eb3788b8c9befb42546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Sun, 19 Dec 2021 20:03:54 +0100 Subject: [PATCH] fix(next/jest): do not watch `.next` folder (#32659) `jest --watch` looks for [changes in dotfiles and folders by default](https://github.com/facebook/jest/pull/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` --- packages/next/build/jest/jest.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/next/build/jest/jest.ts b/packages/next/build/jest/jest.ts index 644d5cd115e1..92b1a7737b5e 100644 --- a/packages/next/build/jest/jest.ts +++ b/packages/next/build/jest/jest.ts @@ -95,7 +95,7 @@ export default function nextJest(options: { dir?: string } = {}) { testPathIgnorePatterns: [ // Don't look for tests in node_modules '/node_modules/', - // Don't look for tests in the the Next.js build output + // Don't look for tests in the Next.js build output '/.next/', // Custom config can append to testPathIgnorePatterns but not modify it // This is to ensure `.next` and `node_modules` are always excluded @@ -127,6 +127,11 @@ export default function nextJest(options: { dir?: string } = {}) { // This is to ensure `node_modules` and .module.css/sass/scss are always excluded ...(resolvedJestConfig.transformIgnorePatterns || []), ], + watchPathIgnorePatterns: [ + // Don't re-run tests when the Next.js build output changes + '/.next/', + ...(resolvedJestConfig.watchPathIgnorePatterns || []), + ], } } }