Skip to content

Commit 37244d9

Browse files
committed
feat(@angular/cli): add --config-file option to ng test
Closes angular#183
1 parent 9548d90 commit 37244d9

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface TestOptions {
1414
build?: boolean;
1515
sourcemap?: boolean;
1616
progress?: boolean;
17+
configFile?: string;
1718
}
1819

1920

@@ -29,7 +30,8 @@ const TestCommand = EmberTestCommand.extend({
2930
{ name: 'port', type: Number },
3031
{ name: 'reporters', type: String },
3132
{ name: 'build', type: Boolean, default: true },
32-
{ name: 'sourcemap', type: Boolean, default: true, aliases: ['sm'] }
33+
{ name: 'sourcemap', type: Boolean, default: true, aliases: ['sm'] },
34+
{ name: 'config-file', type: String }
3335
],
3436

3537
run: function(commandOptions: TestOptions) {

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
const Task = require('../ember-cli/lib/models/task');
22
import { TestOptions } from '../commands/test';
33
import * as path from 'path';
4+
import * as fs from 'fs';
45
import { requireDependency } from '../utilities/require-project-module';
56

67
export default Task.extend({
78
run: function (options: TestOptions) {
89
const projectRoot = this.project.root;
910
return new Promise((resolve) => {
1011
const karma = requireDependency(projectRoot, 'karma');
11-
const karmaConfig = path.join(projectRoot, this.project.ngConfig.config.test.karma.config);
12+
const karmaConfig = options.configFile ?
13+
path.resolve(projectRoot, options.configFile) :
14+
path.join(projectRoot, this.project.ngConfig.config.test.karma.config);
1215

1316
let karmaOptions: any = Object.assign({}, options);
1417

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ng } from '../../utils/process';
2+
import { copyFile } from '../../utils/fs';
3+
4+
export default function () {
5+
// make sure both --watch=false and --single-run work
6+
return Promise.resolve(copyFile('karma.conf.js', 'kc.js'))
7+
.then(() => ng('test', '--single-run', '--config-file', 'kc.js'));
8+
}

0 commit comments

Comments
 (0)