Skip to content

Commit bfb0a66

Browse files
committed
feat: add nyc for unit test code coverage
Signed-off-by: BoHong Li <[email protected]>
1 parent 5575e08 commit bfb0a66

File tree

3 files changed

+836
-25
lines changed

3 files changed

+836
-25
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ public/views/build
2727

2828
public/uploads/*
2929
!public/uploads/.gitkeep
30+
/.nyc_output
31+
/coverage/

package.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
"jsonlint": "find . -not -path './node_modules/*' -type f -name '*.json' -o -type f -name '*.json.example' | while read json; do echo $json ; jq . $json; done",
2323
"standard": "echo 'standard is no longer being used, use `npm run eslint` instead!' && exit 1",
2424
"start": "sequelize db:migrate && node app.js",
25-
"test": "npm run-script eslint && npm run-script jsonlint && mocha"
25+
"mocha": "mocha --require intelli-espower-loader --exit ./test --recursive",
26+
"cov": "nyc mocha --require intelli-espower-loader --exit --recursive ./test",
27+
"test": "npm run-script eslint && npm run-script jsonlint && npm run-script mocha"
2628
},
2729
"dependencies": {
2830
"@hackmd/codemirror": "~5.41.2",
@@ -162,15 +164,19 @@
162164
"file-loader": "~2.0.0",
163165
"html-webpack-plugin": "~4.0.0-beta.2",
164166
"imports-loader": "~0.8.0",
167+
"intelli-espower-loader": "^1.0.1",
165168
"jsonlint": "~1.6.2",
166169
"less": "~3.9.0",
167170
"less-loader": "~4.1.0",
168171
"mini-css-extract-plugin": "~0.4.1",
169172
"mocha": "~5.2.0",
170173
"mock-require": "~3.0.3",
174+
"nyc": "^14.0.0",
171175
"optimize-css-assets-webpack-plugin": "~5.0.0",
176+
"power-assert": "^1.6.1",
172177
"script-loader": "~0.7.2",
173178
"sequelize-cli": "~5.4.0",
179+
"sinon": "^7.3.2",
174180
"string-loader": "~0.0.1",
175181
"style-loader": "~0.21.0",
176182
"uglifyjs-webpack-plugin": "~1.2.7",
@@ -196,5 +202,13 @@
196202
"name": "Christoph (Sheogorath) Kern",
197203
"email": "[email protected]"
198204
}
199-
]
205+
],
206+
"nyc": {
207+
"all": true,
208+
"include": [
209+
"app.js",
210+
"lib/**/*.js"
211+
],
212+
"reporter": "lcov"
213+
}
200214
}

0 commit comments

Comments
 (0)