diff --git a/packages/angular-cli/tasks/test.ts b/packages/angular-cli/tasks/test.ts index 56ba9e1c1d87..43527b5ac5cf 100644 --- a/packages/angular-cli/tasks/test.ts +++ b/packages/angular-cli/tasks/test.ts @@ -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();