From b9295e08e76712e95dad30ea56cd51bb1be79986 Mon Sep 17 00:00:00 2001 From: ruffiem Date: Fri, 10 Feb 2017 13:32:02 +0100 Subject: [PATCH] feat(@angular/cli): added argument for karma configuration file (#4564) Fix #183 --- packages/@angular/cli/commands/test.ts | 2 ++ packages/@angular/cli/tasks/test.ts | 3 ++- tests/e2e/tests/test/test.ts | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/@angular/cli/commands/test.ts b/packages/@angular/cli/commands/test.ts index 5014fda76837..a51aea65cabd 100644 --- a/packages/@angular/cli/commands/test.ts +++ b/packages/@angular/cli/commands/test.ts @@ -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 }, diff --git a/packages/@angular/cli/tasks/test.ts b/packages/@angular/cli/tasks/test.ts index 084d7c603ffc..4017737d5fbc 100644 --- a/packages/@angular/cli/tasks/test.ts +++ b/packages/@angular/cli/tasks/test.ts @@ -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); diff --git a/tests/e2e/tests/test/test.ts b/tests/e2e/tests/test/test.ts index ed4ea6c5f0d4..2acbd339b7c6 100644 --- a/tests/e2e/tests/test/test.ts +++ b/tests/e2e/tests/test/test.ts @@ -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')); }