diff --git a/packages/angular_devkit/build_angular/src/builders/karma/application_builder.ts b/packages/angular_devkit/build_angular/src/builders/karma/application_builder.ts index f82a3b0da1b8..3ac5a360960a 100644 --- a/packages/angular_devkit/build_angular/src/builders/karma/application_builder.ts +++ b/packages/angular_devkit/build_angular/src/builders/karma/application_builder.ts @@ -265,28 +265,33 @@ async function initializeApplication( karmaOptions.files ??= []; karmaOptions.files.push( // Serve polyfills first. - { pattern: `${outputPath}/polyfills.js`, type: 'module' }, + { pattern: `${outputPath}/polyfills.js`, type: 'module', watched: false }, // Serve global setup script. - { pattern: `${outputPath}/${mainName}.js`, type: 'module' }, + { pattern: `${outputPath}/${mainName}.js`, type: 'module', watched: false }, // Serve all source maps. - { pattern: `${outputPath}/*.map`, included: false }, + { pattern: `${outputPath}/*.map`, included: false, watched: false }, ); if (hasChunkOrWorkerFiles(buildOutput.files)) { karmaOptions.files.push( // Allow loading of chunk-* files but don't include them all on load. - { pattern: `${outputPath}/{chunk,worker}-*.js`, type: 'module', included: false }, + { + pattern: `${outputPath}/{chunk,worker}-*.js`, + type: 'module', + included: false, + watched: false, + }, ); } karmaOptions.files.push( // Serve remaining JS on page load, these are the test entrypoints. - { pattern: `${outputPath}/*.js`, type: 'module' }, + { pattern: `${outputPath}/*.js`, type: 'module', watched: false }, ); if (options.styles?.length) { // Serve CSS outputs on page load, these are the global styles. - karmaOptions.files.push({ pattern: `${outputPath}/*.css`, type: 'css' }); + karmaOptions.files.push({ pattern: `${outputPath}/*.css`, type: 'css', watched: false }); } const parsedKarmaConfig: Config & ConfigOptions = await karma.config.parseConfig( diff --git a/packages/angular_devkit/build_angular/src/builders/karma/tests/behavior/rebuilds_spec.ts b/packages/angular_devkit/build_angular/src/builders/karma/tests/behavior/rebuilds_spec.ts index a89f2dbd7c7a..2f4ae93cc134 100644 --- a/packages/angular_devkit/build_angular/src/builders/karma/tests/behavior/rebuilds_spec.ts +++ b/packages/angular_devkit/build_angular/src/builders/karma/tests/behavior/rebuilds_spec.ts @@ -11,7 +11,7 @@ import { execute } from '../../index'; import { BASE_OPTIONS, KARMA_BUILDER_INFO, describeKarmaBuilder } from '../setup'; import { BuilderOutput } from '@angular-devkit/architect'; -describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget, isApplicationBuilder) => { +describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => { describe('Behavior: "Rebuilds"', () => { beforeEach(async () => { await setupTarget(harness); @@ -45,13 +45,6 @@ describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget, isAppli expect(result?.success).toBeTrue(); }, ]; - if (isApplicationBuilder) { - expectedSequence.unshift(async (result) => { - // This is the initial Karma run, it should succeed. - // For simplicity, we trigger a run the first time we build in watch mode. - expect(result?.success).toBeTrue(); - }); - } const buildCount = await harness .execute({ outputLogsOnFailure: false })