feat(@angular/cli): added argument for karma configuration file (#4564)

Fix #183
This commit is contained in:
ruffiem 2017-02-10 13:32:02 +01:00 committed by Filipe Silva
parent 217a87e0b0
commit b9295e08e7
3 changed files with 8 additions and 2 deletions

View File

@ -14,6 +14,7 @@ export interface TestOptions {
build?: boolean;
sourcemap?: boolean;
progress?: boolean;
config: string;
}
@ -21,6 +22,7 @@ const TestCommand = EmberTestCommand.extend({
availableOptions: [
{ name: 'watch', type: Boolean, default: true, aliases: ['w'] },
{ name: 'code-coverage', type: Boolean, default: false, aliases: ['cc'] },
{ name: 'config', type: String, aliases: ['c'] },
{ name: 'single-run', type: Boolean, default: false, aliases: ['sr'] },
{ name: 'progress', type: Boolean, default: true},
{ name: 'browsers', type: String },

View File

@ -8,7 +8,8 @@ export default Task.extend({
const projectRoot = this.project.root;
return new Promise((resolve) => {
const karma = requireProjectModule(projectRoot, 'karma');
const karmaConfig = path.join(projectRoot, this.project.ngConfig.config.test.karma.config);
const karmaConfig = path.join(projectRoot, options.config ||
this.project.ngConfig.config.test.karma.config);
let karmaOptions: any = Object.assign({}, options);

View File

@ -1,7 +1,10 @@
import { ng } from '../../utils/process';
import { moveFile } from '../../utils/fs';
export default function () {
// make sure both --watch=false and --single-run work
return ng('test', '--single-run')
.then(() => ng('test', '--watch=false'));
.then(() => ng('test', '--watch=false'))
.then(() => moveFile('./karma.conf.js', './karma.conf.bis.js'))
.then(() => ng('test', '--single-run', '--config', 'karma.conf.bis.js'));
}