Skip to content

Commit

Permalink
feat(@angular/cli): add --config-file option to ng test
Browse files Browse the repository at this point in the history
  • Loading branch information
Brocco committed Feb 9, 2017
1 parent 9548d90 commit 37244d9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/@angular/cli/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface TestOptions {
build?: boolean;
sourcemap?: boolean;
progress?: boolean;
configFile?: string;
}


Expand All @@ -29,7 +30,8 @@ const TestCommand = EmberTestCommand.extend({
{ name: 'port', type: Number },
{ name: 'reporters', type: String },
{ name: 'build', type: Boolean, default: true },
{ name: 'sourcemap', type: Boolean, default: true, aliases: ['sm'] }
{ name: 'sourcemap', type: Boolean, default: true, aliases: ['sm'] },
{ name: 'config-file', type: String }
],

run: function(commandOptions: TestOptions) {
Expand Down
5 changes: 4 additions & 1 deletion packages/@angular/cli/tasks/test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
const Task = require('../ember-cli/lib/models/task');
import { TestOptions } from '../commands/test';
import * as path from 'path';
import * as fs from 'fs';
import { requireDependency } from '../utilities/require-project-module';

export default Task.extend({
run: function (options: TestOptions) {
const projectRoot = this.project.root;
return new Promise((resolve) => {
const karma = requireDependency(projectRoot, 'karma');
const karmaConfig = path.join(projectRoot, this.project.ngConfig.config.test.karma.config);
const karmaConfig = options.configFile ?
path.resolve(projectRoot, options.configFile) :
path.join(projectRoot, this.project.ngConfig.config.test.karma.config);

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

Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/tests/test/test-config-file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ng } from '../../utils/process';
import { copyFile } from '../../utils/fs';

export default function () {
// make sure both --watch=false and --single-run work
return Promise.resolve(copyFile('karma.conf.js', 'kc.js'))
.then(() => ng('test', '--single-run', '--config-file', 'kc.js'));
}

0 comments on commit 37244d9

Please sign in to comment.