cypress-typescript-coverage-example
cypress-typescript-coverage-example copied to clipboard
Instrumentation not working
Hello I tried to instrument my project following your example and each test I got an error collecting code coverage :
Could not find any coverage information in your application
by looking at the window coverage object.
Did you forget to instrument your application?
See code-coverage#instrument-your-application
[@cypress/code-coverage]
Here are my files:
.nycrc.json
{
"extends": "@istanbuljs/nyc-config-typescript",
"all": true
}
babel.config.js
const { readFileSync } = require("fs");
const { join } = require("path");
const { CODE_COVERAGE } = process.env;
const plugins = [];
if (CODE_COVERAGE === true) plugins.push("istanbul");
const browsersList = readFileSync(join(__dirname, ".browserslistrc"), "utf8").split("\n");
module.exports = {
presets: [
[
"next/babel",
{
"preset-env": {
targets: browsersList,
},
},
],
],
plugins
};
package.json
{
"name": "my-project",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "CODE_COVERAGE=true ts-node --project tsconfig.server.json server/index.ts",
"start": "NODE_ENV=production node server/index.js",
"cypress": "CODE_COVERAGE=true cypress open --config-file cypress-local.json"
},
"dependencies": {
...
},
"devDependencies": {
"@babel/core": "^7.14.6",
"@cypress/code-coverage": "^3.9.10",
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@types/cypress-cucumber-preprocessor": "^4.0.1",
"babel-loader": "^8.2.2",
"babel-plugin-module-resolver": "^4.1.0",
"source-map-support": "^0.5.19",
"ts-node": "^10.0.0",
"typescript": "4.2.2"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
}
}
Is there a bug with intrumentation ?