Skip to content

Commit

Permalink
fix(karma): Enable test of global scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
YonatanKra committed Nov 12, 2016
1 parent ed0fd3e commit c21e1a9
Showing 1 changed file with 21 additions and 0 deletions.
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) => {
// 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

0 comments on commit c21e1a9

Please sign in to comment.