From 3e7b1674cb9eb64c5deea5bcb831fabcbcfae2a5 Mon Sep 17 00:00:00 2001 From: mru Date: Thu, 9 Feb 2017 16:53:23 +0100 Subject: [PATCH 1/5] (feat) added argument for karma configuration file --- packages/@angular/cli/commands/test.ts | 2 ++ packages/@angular/cli/tasks/test.ts | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/@angular/cli/commands/test.ts b/packages/@angular/cli/commands/test.ts index 5014fda76837..2ab8b9e9735d 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; + configFile: 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-file', type: Boolean, default: false, aliases: ['c', 'cf'] }, { 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 d6dcba48a6fa..d9fc20ccab54 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 = requireDependency(projectRoot, 'karma'); - const karmaConfig = path.join(projectRoot, this.project.ngConfig.config.test.karma.config); + const karmaConfig = path.join(projectRoot, options.configFile || + this.project.ngConfig.config.test.karma.config); let karmaOptions: any = Object.assign({}, options); From 11da5352e71bf2024f7d8a46de3bc26ec73c09f6 Mon Sep 17 00:00:00 2001 From: mru Date: Thu, 9 Feb 2017 18:09:21 +0100 Subject: [PATCH 2/5] (e2e) added test + (bug) fixed type --- packages/@angular/cli/commands/test.ts | 2 +- tests/e2e/tests/test/test.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/@angular/cli/commands/test.ts b/packages/@angular/cli/commands/test.ts index 2ab8b9e9735d..0fb5f6ad3d4e 100644 --- a/packages/@angular/cli/commands/test.ts +++ b/packages/@angular/cli/commands/test.ts @@ -22,7 +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-file', type: Boolean, default: false, aliases: ['c', 'cf'] }, + { name: 'config-file', type: String, aliases: ['c', 'cf'] }, { name: 'single-run', type: Boolean, default: false, aliases: ['sr'] }, { name: 'progress', type: Boolean, default: true}, { name: 'browsers', type: String }, diff --git a/tests/e2e/tests/test/test.ts b/tests/e2e/tests/test/test.ts index ed4ea6c5f0d4..f94e09e377f3 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 { copyFile } 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(() => copyFile('./karma.conf.js', './karma.conf.bis.js')) + .then(() => ng('test', '--single-run', '--config-file', 'karma.conf.bis.js')); } From d9e064a88e87b138d046c922229ce8033f3473ca Mon Sep 17 00:00:00 2001 From: mru Date: Thu, 9 Feb 2017 18:33:20 +0100 Subject: [PATCH 3/5] (update) changed config-file flag to config for consistency --- packages/@angular/cli/commands/test.ts | 4 ++-- packages/@angular/cli/ember-cli/lib/commands/test.js | 2 +- packages/@angular/cli/tasks/test.ts | 2 +- tests/e2e/tests/test/test.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/@angular/cli/commands/test.ts b/packages/@angular/cli/commands/test.ts index 0fb5f6ad3d4e..78d5877ca452 100644 --- a/packages/@angular/cli/commands/test.ts +++ b/packages/@angular/cli/commands/test.ts @@ -14,7 +14,7 @@ export interface TestOptions { build?: boolean; sourcemap?: boolean; progress?: boolean; - configFile: string; + config: string; } @@ -22,7 +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-file', type: String, aliases: ['c', 'cf'] }, + { name: 'config', type: String, aliases: ['c', 'cf'] }, { 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/ember-cli/lib/commands/test.js b/packages/@angular/cli/ember-cli/lib/commands/test.js index 6839207c6996..49db23a27a35 100644 --- a/packages/@angular/cli/ember-cli/lib/commands/test.js +++ b/packages/@angular/cli/ember-cli/lib/commands/test.js @@ -13,7 +13,7 @@ module.exports = Command.extend({ availableOptions: [ { name: 'environment', type: String, default: 'test', aliases: ['e'] }, - { name: 'config-file', type: String, aliases: ['c', 'cf']}, + { name: 'config', type: String, aliases: ['c', 'cf']}, { name: 'server', type: Boolean, default: false, aliases: ['s'] }, { name: 'host', type: String, aliases: ['H'] }, { name: 'test-port', type: Number, default: defaultPort, aliases: ['tp'], description: 'The test port to use when running with --server.' }, diff --git a/packages/@angular/cli/tasks/test.ts b/packages/@angular/cli/tasks/test.ts index d9fc20ccab54..121e0b5e2284 100644 --- a/packages/@angular/cli/tasks/test.ts +++ b/packages/@angular/cli/tasks/test.ts @@ -8,7 +8,7 @@ export default Task.extend({ const projectRoot = this.project.root; return new Promise((resolve) => { const karma = requireDependency(projectRoot, 'karma'); - const karmaConfig = path.join(projectRoot, options.configFile || + 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 f94e09e377f3..b37a6682a1ef 100644 --- a/tests/e2e/tests/test/test.ts +++ b/tests/e2e/tests/test/test.ts @@ -6,5 +6,5 @@ export default function () { return ng('test', '--single-run') .then(() => ng('test', '--watch=false')) .then(() => copyFile('./karma.conf.js', './karma.conf.bis.js')) - .then(() => ng('test', '--single-run', '--config-file', 'karma.conf.bis.js')); + .then(() => ng('test', '--single-run', '--config', 'karma.conf.bis.js')); } From d4662cfb7c54b96d5ba09352e84896fc65fb0ebe Mon Sep 17 00:00:00 2001 From: mru Date: Fri, 10 Feb 2017 10:30:40 +0100 Subject: [PATCH 4/5] (fix) updated function name --- packages/@angular/cli/tasks/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@angular/cli/tasks/test.ts b/packages/@angular/cli/tasks/test.ts index d67c37cc5943..4017737d5fbc 100644 --- a/packages/@angular/cli/tasks/test.ts +++ b/packages/@angular/cli/tasks/test.ts @@ -7,7 +7,7 @@ export default Task.extend({ run: function (options: TestOptions) { const projectRoot = this.project.root; return new Promise((resolve) => { - const karma = requireDependency(projectRoot, 'karma'); + const karma = requireProjectModule(projectRoot, 'karma'); const karmaConfig = path.join(projectRoot, options.config || this.project.ngConfig.config.test.karma.config); From 01e7fef43ab72d3138359aaabdcf67428f9f64d6 Mon Sep 17 00:00:00 2001 From: mru Date: Fri, 10 Feb 2017 12:46:52 +0100 Subject: [PATCH 5/5] (update) requested changes --- packages/@angular/cli/commands/test.ts | 2 +- packages/@angular/cli/ember-cli/lib/commands/test.js | 2 +- tests/e2e/tests/test/test.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/@angular/cli/commands/test.ts b/packages/@angular/cli/commands/test.ts index 78d5877ca452..a51aea65cabd 100644 --- a/packages/@angular/cli/commands/test.ts +++ b/packages/@angular/cli/commands/test.ts @@ -22,7 +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', 'cf'] }, + { 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/ember-cli/lib/commands/test.js b/packages/@angular/cli/ember-cli/lib/commands/test.js index 49db23a27a35..6839207c6996 100644 --- a/packages/@angular/cli/ember-cli/lib/commands/test.js +++ b/packages/@angular/cli/ember-cli/lib/commands/test.js @@ -13,7 +13,7 @@ module.exports = Command.extend({ availableOptions: [ { name: 'environment', type: String, default: 'test', aliases: ['e'] }, - { name: 'config', type: String, aliases: ['c', 'cf']}, + { name: 'config-file', type: String, aliases: ['c', 'cf']}, { name: 'server', type: Boolean, default: false, aliases: ['s'] }, { name: 'host', type: String, aliases: ['H'] }, { name: 'test-port', type: Number, default: defaultPort, aliases: ['tp'], description: 'The test port to use when running with --server.' }, diff --git a/tests/e2e/tests/test/test.ts b/tests/e2e/tests/test/test.ts index b37a6682a1ef..2acbd339b7c6 100644 --- a/tests/e2e/tests/test/test.ts +++ b/tests/e2e/tests/test/test.ts @@ -1,10 +1,10 @@ import { ng } from '../../utils/process'; -import { copyFile } from '../../utils/fs'; +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(() => copyFile('./karma.conf.js', './karma.conf.bis.js')) + .then(() => moveFile('./karma.conf.js', './karma.conf.bis.js')) .then(() => ng('test', '--single-run', '--config', 'karma.conf.bis.js')); }