Skip to content

Commit b9295e0

Browse files
ruffiemfilipesilva
ruffiem
authored andcommitted
feat(@angular/cli): added argument for karma configuration file (#4564)
Fix #183
1 parent 217a87e commit b9295e0

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

packages/@angular/cli/commands/test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ export interface TestOptions {
1414
build?: boolean;
1515
sourcemap?: boolean;
1616
progress?: boolean;
17+
config: string;
1718
}
1819

1920

2021
const TestCommand = EmberTestCommand.extend({
2122
availableOptions: [
2223
{ name: 'watch', type: Boolean, default: true, aliases: ['w'] },
2324
{ name: 'code-coverage', type: Boolean, default: false, aliases: ['cc'] },
25+
{ name: 'config', type: String, aliases: ['c'] },
2426
{ name: 'single-run', type: Boolean, default: false, aliases: ['sr'] },
2527
{ name: 'progress', type: Boolean, default: true},
2628
{ name: 'browsers', type: String },

packages/@angular/cli/tasks/test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export default Task.extend({
88
const projectRoot = this.project.root;
99
return new Promise((resolve) => {
1010
const karma = requireProjectModule(projectRoot, 'karma');
11-
const karmaConfig = path.join(projectRoot, this.project.ngConfig.config.test.karma.config);
11+
const karmaConfig = path.join(projectRoot, options.config ||
12+
this.project.ngConfig.config.test.karma.config);
1213

1314
let karmaOptions: any = Object.assign({}, options);
1415

tests/e2e/tests/test/test.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { ng } from '../../utils/process';
2+
import { moveFile } from '../../utils/fs';
23

34
export default function () {
45
// make sure both --watch=false and --single-run work
56
return ng('test', '--single-run')
6-
.then(() => ng('test', '--watch=false'));
7+
.then(() => ng('test', '--watch=false'))
8+
.then(() => moveFile('./karma.conf.js', './karma.conf.bis.js'))
9+
.then(() => ng('test', '--single-run', '--config', 'karma.conf.bis.js'));
710
}

0 commit comments

Comments
 (0)