Skip to content

Commit

Permalink
feat(@angular/cli): added argument for karma configuration file (#4564)
Browse files Browse the repository at this point in the history
Fix #183
  • Loading branch information
ruffiem authored and filipesilva committed Feb 10, 2017
1 parent 217a87e commit b9295e0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/@angular/cli/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ export interface TestOptions {
build?: boolean;
sourcemap?: boolean;
progress?: boolean;
config: string;
}


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 },
Expand Down
3 changes: 2 additions & 1 deletion packages/@angular/cli/tasks/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion tests/e2e/tests/test/test.ts
Original file line number Diff line number Diff line change
@@ -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'));
}

0 comments on commit b9295e0

Please sign in to comment.