Skip to content

Commit 72447cd

Browse files
committed
feat: code coverage support for babel+browser-do setup
1 parent d6c06ca commit 72447cd

4 files changed

Lines changed: 35 additions & 2 deletions

File tree

common/.babelrc__if_babel

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,11 @@
1010
// @endif
1111
["@babel/plugin-proposal-class-properties", { loose: true }],
1212
"@babel/plugin-syntax-dynamic-import"
13-
]
13+
]/* @if (jasmine || mocha || tape) && !sfc */,
14+
"env": {
15+
"test": {
16+
"plugins": [ "istanbul" ]
17+
}
18+
}
19+
/* @endif */
1420
}

common/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Thumbs.db
1212
# Compiled files
1313
/dist
1414
/index.html
15+
/.nyc_output
16+
/coverage
1517

1618
// @if cypress
1719
/cypress/videos

common/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,21 @@ This runs in Chrome, if you want to use other browser, update package.json "brow
5252

5353
By default, browser-do closes the browser after tests finish, to keep browser running, use `--keep-open` option on browser-do command.
5454
// @endif
55+
56+
// @if jest
57+
## Code coverage
58+
59+
`npm test` already generetes code coverage report, you can open `coverage/lcov-report/index.html` for detailed report.
60+
61+
// @endif
62+
// @if babel && (jasmine || mocha || tape) && !sfc
63+
## Code coverage
64+
65+
npm run coverage
66+
67+
Then open `coverage/lcov-report/index.html` for detailed report.
68+
69+
// @if react
70+
> Currently coverage doesn't work for out react setup. To be fixed.
71+
// @endif
72+
// @endif

common/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
"@babel/plugin-proposal-class-properties": "^7.4.0",
1414
"gulp-babel": "^8.0.0",
1515
"regenerator-runtime": "0.13.2",
16+
// @if (jasmine || mocha || tape) && !sfc
17+
"babel-plugin-istanbul": "^5.1.4",
18+
"nyc": "^14.1.1",
19+
// @endif
1620
// @endif
1721

1822
// @if babel || cypress
@@ -37,7 +41,7 @@
3741
// @endif
3842

3943
// @if jasmine || tape || mocha
40-
"browser-do": "^0.2.0",
44+
"browser-do": "^0.3.2",
4145
// @endif
4246

4347
// @if !sfc
@@ -80,6 +84,9 @@
8084
// @if jasmine || tape || mocha
8185
"pretest": "npm run lint && npm run build:test",
8286
"build:test": "gulp clean && cross-env NODE_ENV=test gulp build",
87+
// @if babel && !sfc
88+
"coverage": "npm run test && nyc report --reporter=lcov --reporter=text",
89+
// @endif
8390
// @endif
8491
"start": "gulp",
8592
"start:prod": "cross-env NODE_ENV=production gulp",

0 commit comments

Comments
 (0)