Open coderhammer opened 4 months ago
We just toss everything into the c8
module and let it work, but it won't have had access to scripts (and sourcemaps) from the runtime.
I plan to rework coverage shortly with the addition of attributable coverage in VS Code (based on https://github.com/microsoft/vscode/pull/212325) which does not have this issue.
I admit I don't understand quite well all the mechanisms, but I guess I'll be waiting that this gets implemented! Thanks for taking the time to respond :) I'll try to take some time to explore how c8 works exactly and how it relates to this project
Hey there @coderhammer, it seems to work just fine for me.
package.json
"engines": {
"node": "20.x"
},
"main": "dist/src/functions/index.js",
"scripts": {
"build": "tsc --project tsconfig.json && tscpaths -p tsconfig.json -s ./ -o ./dist",
"watch": "tsc -w",
"clean": "rimraf dist",
"prestart": "npm run clean && npm run build",
"start": "func start",
"pretest": "npm run clean && npm run build",
"test": "node ./dist/__tests__",
"test:debug": "npm run pretest && node --inspect-brk ./dist/__tests__",
"test:html": "nyc --reporter=html node dist/__tests__ && start coverage/index.html",
"posttest": "nyc --reporter=lcov --reporter=text node dist/__tests__"
},
settings.json (user settings)
"nodejs-testing.extensions": [
{
"extensions": ["mjs", "cjs", "js"],
"parameters": []
},
{
"extensions": ["mts", "cts", "ts"],
"parameters": ["--import", "tsx"]
}
],
"nodejs-testing.nodejsPath": "C:\\Program Files\\nodejs\\node.exe",
tsconfig.json
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Node 20",
"include": ["src/**/*.ts", "__tests__/**/*.ts"],
"exclude": ["dist", "node_modules/*"],
"compilerOptions": {
"lib": ["es2022"],
"module": "commonjs",
"target": "es6",
"outDir": "dist",
"rootDir": ".",
"sourceMap": true,
"strict": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"baseUrl": "./src",
"paths": {
"Models": ["models/index"],
"Container": ["container/index"],
"Availability": ["modules/availability/index"],
"Agenda": ["modules/agenda/index"],
"Shared": ["modules/shared/index"],
"Utils": ["utils/index"],
"Errors": ["errors/index"],
"Authentication": ["authentication/index"],
"Middlewares": ["middlewares/index"],
"Functions": ["functions/index"]
}
}
}
Hey, I'm trying the new code coverage feature, first of all, thank you for the work.
It doesn't work for me, I don't know if I'm missing some configuration. Currently using this configuration:
Everything works well except test coverage, I only have this that appears:
And everthing shows up as 100%:
So it looks like something does not work. When I run the following command by hand:
I obtain:
So the node test runner seems to recognise my files.
Are you aware of such a thing? Can I help you with identifying the root cause?
Thank you for your time and have a nice day