Skip to content
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

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

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
});
Expand Up @@ -336,7 +336,17 @@ function fallbackMiddleware() {
function isPlugin(moduleId: string, pluginName: string) {
alan-agius4 marked this conversation as resolved.
Show resolved Hide resolved
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