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(karma): Enable test of global scripts #3122

Closed
Closed
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
21 changes: 21 additions & 0 deletions packages/angular-cli/tasks/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,27 @@ export default Task.extend({
// Assign additional karmaConfig options to the local ngapp config
options.configFile = karmaConfig;

options.files = [
{pattern: './src/test.ts', watched: false}
];

// get the project's global scripts
const scripts = this.project.ngConfig.config.apps[0].scripts;
// if scripts exist, we should add them to Karma files
if (scripts.length) {
// add each script to the files array
options.files.push.apply(options.files, scripts.map((script: any) => {
// if script has node modules in it, we assume it is something local
// otherwise we just take it as a URL

if (script.indexOf('node_modules') > -1) {
// script = path.resolve(path.join(rootPath, script));
script = script.replace('..', '.');
}

return {pattern: script, watched: false, included: true, served: true};
}));
}
// :shipit:
const karmaServer = new karma.Server(options, resolve);
karmaServer.start();
Expand Down