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 || []), + ], } } }