diff --git a/npm/webpack-dev-server/src/makeDefaultWebpackConfig.ts b/npm/webpack-dev-server/src/makeDefaultWebpackConfig.ts index 2ae88af47f6b..f40ca731bc0a 100644 --- a/npm/webpack-dev-server/src/makeDefaultWebpackConfig.ts +++ b/npm/webpack-dev-server/src/makeDefaultWebpackConfig.ts @@ -99,11 +99,13 @@ export function makeCypressWebpackConfig ( devtool: 'inline-source-map', } as any - // if experimentalJustInTimeCompile is configured, we need to watch for file changes as the spec entries are going to be updated per test - if (isRunMode && !experimentalJustInTimeCompile) { + if (isRunMode) { + // if experimentalJustInTimeCompile is configured, we need to watch for file changes as the spec entries are going to be updated per test + const ignored = experimentalJustInTimeCompile ? /node_modules/ : '**/*' + // Disable file watching when executing tests in `run` mode finalConfig.watchOptions = { - ignored: '**/*', + ignored, } } diff --git a/npm/webpack-dev-server/test/makeWebpackConfig.spec.ts b/npm/webpack-dev-server/test/makeWebpackConfig.spec.ts index ac9dc29cfdd2..31d18a8713e0 100644 --- a/npm/webpack-dev-server/test/makeWebpackConfig.spec.ts +++ b/npm/webpack-dev-server/test/makeWebpackConfig.spec.ts @@ -495,7 +495,7 @@ describe('makeWebpackConfig', () => { }), }) - expect(actual.watchOptions?.ignored).to.be.undefined + expect(actual.watchOptions?.ignored).to.deep.equal(/node_modules/) }) }) })