Repository navigation
fix(@angular/build): warn about unsupported options in the unit-test karma runner #34546
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
Merged
alan-agius4
merged 3 commits into
angular:main
from
MeAkib:fix/karma-runner-unsupported-option-warnings
Oct 28, 2026
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/angular/build/src/builders/unit-test/runners/karma/executor_spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /** | ||
|
alan-agius4 marked this conversation as resolved.
Resolved
|
||
| * @license | ||
| * Copyright Google LLC All Rights Reserved. | ||
| * | ||
| * Use of this source code is governed by an MIT-style license that can be | ||
| * found in the LICENSE file at https://angular.dev/license | ||
| */ | ||
|
|
||
| import type { BuilderContext } from '@angular-devkit/architect'; | ||
| import type { NormalizedUnitTestBuilderOptions } from '../../options'; | ||
| import { KarmaExecutor } from './executor'; | ||
|
|
||
| describe('KarmaExecutor', () => { | ||
| async function getWarnings(options: Record<string, unknown>): Promise<string[]> { | ||
| const warn = jasmine.createSpy('warn'); | ||
| // The unsupported option warnings are logged before the build target is read, so stop there. | ||
| const context = { | ||
| logger: { warn }, | ||
| getTargetOptions: () => Promise.reject(new Error('stop')), | ||
| } as unknown as BuilderContext; | ||
|
|
||
| const executor = new KarmaExecutor(context, { | ||
| setupFiles: [], | ||
| coverage: { enabled: false }, | ||
| ...options, | ||
| } as unknown as NormalizedUnitTestBuilderOptions); | ||
|
|
||
| await expectAsync(executor.execute()[Symbol.asyncIterator]().next()).toBeRejectedWithError( | ||
| 'stop', | ||
| ); | ||
|
|
||
| return warn.calls.allArgs().map(([message]) => message); | ||
| } | ||
|
|
||
| it('warns that the "providersFile" option is not supported', async () => { | ||
| expect(await getWarnings({ providersFile: '/src/test-providers.ts' })).toContain( | ||
| 'The "karma" test runner does not support the "providersFile" option. The option will be ignored.', | ||
| ); | ||
| }); | ||
|
|
||
| it('warns that the "outputFile" option is not supported', async () => { | ||
| expect(await getWarnings({ outputFile: 'test-results.xml' })).toContain( | ||
| 'The "karma" test runner does not support the "outputFile" option. The option will be ignored.', | ||
| ); | ||
| }); | ||
|
|
||
| it('warns that the "coverageReporters" option is not supported', async () => { | ||
| expect(await getWarnings({ coverage: { enabled: true, reporters: [['lcov', {}]] } })).toContain( | ||
| 'The "karma" test runner does not support the "coverageReporters" option. The option will be ignored.', | ||
| ); | ||
| }); | ||
|
|
||
| it('does not warn when no unsupported options are set', async () => { | ||
| expect(await getWarnings({})).toEqual([]); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.