Skip to content

fix(@angular-devkit/build-angular): fixed ignoring of karma plugins config #19994

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,16 @@ describe('Karma Builder code coverage', () => {
expect(success).toBe(true);
await run.stop();
}, 120000);

it('is able to process coverage plugins provided as string karma-*', async () => {
host.replaceInFile('karma.conf.js', /plugins: \[.+?\]/s, `plugins: [
'karma-*',
require('@angular-devkit/build-angular/plugins/karma'),
]`);
const run = await architect.scheduleTarget(karmaTargetSpec, { codeCoverage: true });

const {success} = await run.result;
expect(success).toBe(true);
await run.stop();
}, 120000);
});
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,17 @@ function fallbackMiddleware() {
function isPlugin(moduleId: string, pluginName: string) {
return (plugin: string|{}): boolean => {
if (typeof plugin === 'string') {
return plugin === moduleId;
if (!plugin.includes('*')) {
return plugin === moduleId;
}
const regexp = new RegExp(`^${plugin.replace('*', '.*')}`);
if (regexp.test(moduleId)) {
try {
require.resolve(moduleId);
return true;
} catch {}
}
return false;
}
return pluginName in plugin;
}
Expand Down