Skip to content

Commit a11a420

Browse files
filipesilvaMRHarrison
authored andcommitted
chore(test): add --single-run option (angular#2841)
Doing `ng test --single-run` always worked but outputted a ember-cli warning about a missing option. This PR allows using the option without warning. It's overall better than `--watch=false` because it better aligns with Karma's options. `--watch=false` still works though.
1 parent 0359e96 commit a11a420

File tree

11 files changed

+13
-10
lines changed

11 files changed

+13
-10
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ or `ng serve --prod` will also make use of uglifying and tree-shaking functional
185185
ng test
186186
```
187187

188-
Tests will execute after a build is executed via [Karma](http://karma-runner.github.io/0.13/index.html), and it will automatically watch your files for changes. You can run tests a single time via `--watch=false`.
188+
Tests will execute after a build is executed via [Karma](http://karma-runner.github.io/0.13/index.html), and it will automatically watch your files for changes. You can run tests a single time via `--watch=false` or `--single-run`.
189189

190190
### Running end-to-end tests
191191

packages/angular-cli/commands/test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const NgCliTestCommand = TestCommand.extend({
77
{ name: 'watch', type: Boolean, default: true, aliases: ['w'] },
88
{ name: 'code-coverage', type: Boolean, default: false, aliases: ['cc'] },
99
{ name: 'lint', type: Boolean, default: false, aliases: ['l'] },
10+
{ name: 'single-run', type: Boolean, default: false, aliases: ['sr'] },
1011
{ name: 'browsers', type: String },
1112
{ name: 'colors', type: Boolean },
1213
{ name: 'log-level', type: String },

tests/e2e/tests/generate/class.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ export default function() {
1212
.then(() => expectFileToExist(join(classDir, 'test-class.spec.ts')))
1313

1414
// Try to run the unit tests.
15-
.then(() => ng('test', '--watch=false'));
15+
.then(() => ng('test', '--single-run'));
1616
}

tests/e2e/tests/generate/component/component-basic.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ export default function() {
1414
.then(() => expectFileToExist(join(componentDir, 'test-component.component.css')))
1515

1616
// Try to run the unit tests.
17-
.then(() => ng('test', '--watch=false'));
17+
.then(() => ng('test', '--single-run'));
1818
}

tests/e2e/tests/generate/interface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ export default function() {
1111
.then(() => expectFileToExist(join(interfaceDir, 'test-interface.model.ts')))
1212

1313
// Try to run the unit tests.
14-
.then(() => ng('test', '--watch=false'));
14+
.then(() => ng('test', '--single-run'));
1515
}

tests/e2e/tests/generate/module/module-basic.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ export default function() {
1717
.then(() => expectFileToExist(join(moduleDir, 'test-module.component.css')))
1818

1919
// Try to run the unit tests.
20-
.then(() => ng('test', '--watch=false'));
20+
.then(() => ng('test', '--single-run'));
2121
}

tests/e2e/tests/generate/module/module-routing.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ export default function() {
1616
.then(() => expectFileToExist(join(moduleDir, 'test-module.component.css')))
1717

1818
// Try to run the unit tests.
19-
.then(() => ng('test', '--watch=false'));
19+
.then(() => ng('test', '--single-run'));
2020
}

tests/e2e/tests/generate/pipe.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ export default function() {
1313
.then(() => expectFileToExist(join(pipeDir, 'test-pipe.pipe.spec.ts')))
1414

1515
// Try to run the unit tests.
16-
.then(() => ng('test', '--watch=false'));
16+
.then(() => ng('test', '--single-run'));
1717
}

tests/e2e/tests/generate/service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ export default function() {
1313
.then(() => expectFileToExist(join(serviceDir, 'test-service.service.spec.ts')))
1414

1515
// Try to run the unit tests.
16-
.then(() => ng('test', '--watch=false'));
16+
.then(() => ng('test', '--single-run'));
1717
}

tests/e2e/tests/misc/coverage.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {ng} from '../../utils/process';
33

44

55
export default function() {
6-
return ng('test', '--watch=false', '--code-coverage')
6+
return ng('test', '--single-run', '--code-coverage')
77
.then(() => expectFileToExist('coverage/src/app'))
88
.then(() => expectFileToExist('coverage/coverage.lcov'));
99
}

tests/e2e/tests/test/test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ import {ng} from '../../utils/process';
22

33

44
export default function() {
5-
return ng('test', '--watch=false');
5+
// make sure both --watch=false and --single-run work
6+
return ng('test', '--single-run')
7+
.then(() => ng('test', '--watch=false'));
68
}

0 commit comments

Comments
 (0)