Skip to content

Commit c7ebe37

Browse files
committed
Setup nyc to produce code coverage reports
This extends the public TypeScript configuration and sets it to check just our source files. The `all` setting must be `false` otherwise the tool crashes with an OOM because the test runner launches VS Code instances. The `.vscode-test` folder must be excluded or `nyc` will attempt to instrument Code's own sources. The `out` and `src` folders must both be included so that the TypeScript source mapping works. The coverage check is set to false because we'll enable failures for reduced coverage later. The Cobertura report is for Azure DevOps (cobertura) and a summary is printed to the console.
1 parent 4c8989d commit c7ebe37

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,26 @@
8484
"lint": "tslint --project tsconfig.json",
8585
"build": "tsc --project tsconfig.json && esbuild ./src/main.ts --outdir=out --sourcemap --bundle --minify --external:vscode --platform=node",
8686
"test": "node ./out/test/runTests.js",
87+
"coverage": "nyc node ./out/test/runTests.js",
8788
"package": "vsce package --no-gitHubIssueLinking",
8889
"publish": "vsce publish"
8990
},
91+
"nyc": {
92+
"extends": "@istanbuljs/nyc-config-typescript",
93+
"all": false,
94+
"check-coverage": false,
95+
"include": [
96+
"out/**/*.js",
97+
"src/**/*.ts"
98+
],
99+
"exclude": [
100+
".vscode-test/**/*.js"
101+
],
102+
"reporter": [
103+
"cobertura",
104+
"text"
105+
]
106+
},
90107
"contributes": {
91108
"breakpoints": [
92109
{

0 commit comments

Comments
 (0)