Skip to content

Commit 33b3eb5

Browse files
fix(jest): add code coverage flag
1 parent e0537e0 commit 33b3eb5

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"iltorb": "^2.3.2",
8686
"inquirer": "^6.0.0",
8787
"jest": "^23.3.0",
88+
"jest-junit-reporter": "^1.1.0",
8889
"jest-preset-angular": "^5.2.3",
8990
"jest-zone-patch": "0.0.8",
9091
"ng2-fused": "^0.5.1",

src/commands/test.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@ import { resolve } from 'path'
33
const jest = require('jest')
44

55
command(
6-
'test [--watch] [--watchAll]',
6+
'test [--watch] [--coverage]',
77
'run unit-tests on your project',
88
args => {
99
return args
1010
},
1111
args => {
1212
const watch = args.watch || false
13-
const watchAll = args.watchAll || false
14-
test(watch, watchAll)
13+
const coverage = args.coverage || false
14+
test(watch, coverage)
1515
}
1616
)
17-
.option('watch', {
17+
.option('coverage', {
1818
default: false,
19-
description: 're-run tests when files change'
19+
description: 'report on code coverage'
2020
})
21-
.option('watchAll', {
21+
.option('watch', {
2222
default: false,
23-
description: 're-run tests when files change regardless of git diff'
23+
description: 're-run tests when files change'
2424
})
2525

26-
function test(watch: boolean, watchAll: boolean) {
26+
function test(watchAll: boolean, coverage: boolean) {
2727
jest.runCLI(
2828
{
29-
watch,
3029
watchAll,
30+
coverage,
3131
globals: JSON.stringify({
3232
__TRANSFORM_HTML__: true,
3333
'ts-jest': {
@@ -54,6 +54,12 @@ function test(watch: boolean, watchAll: boolean) {
5454
resolve(
5555
'node_modules/fusing-angular-cli/.build/jest/HTMLCommentSerializer.js'
5656
)
57+
],
58+
testResultsProcessor: resolve('node_modules/jest-junit-reporter'),
59+
collectCoverageFrom: [
60+
'src/**/*.{ts,html}',
61+
'!src/browser/app.browser.entry.aot.ts',
62+
'!src/browser/app.browser.entry.jit.ts'
5763
]
5864
},
5965
[resolve(__dirname, '../../')]

0 commit comments

Comments
 (0)