code-coverage: nyc out.json is empty
vue/node js project running with cypress tests, trying to add coverage
the nyc_output folder is there also the processinto folder
The out.json file is either empty or not created, depending on how i play with the setting files
I also see in the cypress run that the after all task - covergereport runs, but the after each task - combine coverge does not run
my plugins index file has the
on('task', require('@cypress/code-coverage/task'))
my babel
"babel": {
"plugins": ["istanbul"],
"presets": [
[
"@babel/preset-env",
{
"modules": "commonjs",
"targets": {
"node": "current"
}
}
]
]
nycrc
{
"extends": "@istanbuljs/nyc-config-babel",
"extension": [".js", ".vue"],
"all": true
}
my command line
nyc --all npm run test:open
my json has
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/preset-env": "^7.5.2",
"@cypress/code-coverage": "^1.10.1",
"@vue/cli-plugin-babel": "^3.8.0",
"@vue/cli-plugin-eslint": "^3.8.0",
"@vue/cli-plugin-unit-jest": "^3.7.0",
"@vue/cli-service": "^3.8.0",
"@vue/eslint-config-standard": "^4.0.0",
"@vue/test-utils": "^1.0.0-beta.29",
"axios-mock-adapter": "^1.17.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^22.4.3",
"babel-plugin-component": "^1.1.1",
"babel-plugin-istanbul": "^5.2.0",
"cypress": "^3.4.1",
"cypress-failed-log": "^2.5.1",
"eslint": "^5.16.0",
"eslint-plugin-cypress": "^2.0.1",
"eslint-plugin-cypress-dev": "2.1.0",
"eslint-plugin-jest": "^22.7.2",
"eslint-plugin-mocha": "5.3.0",
"eslint-plugin-vue": "^5.0.0",
"gulp-babel": "^8.0.0",
"istanbul-lib-coverage": "^2.0.5",
"jest": "^24.8.0",
"jest-html-reporter": "^2.5.0",
"jest-junit": "^6.4.0",
"jest-transform-stub": "^2.0.0",
"nodemon": "^1.19.1",
"nyc": "^14.1.1",
"sass": "^1.18.0",
"sass-loader": "^7.1.0",
"start-server-and-test": "^1.10.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1",
"supertest": "^4.0.2",
"supertest-as-promised": "^4.0.2",
"vue-cli-plugin-vuetify": "^0.5.0",
"vue-jest": "^3.0.4",
"vue-template-compiler": "^2.6.10",
"vue-test-utils": "^1.0.0-beta.11",
"vuetify-loader": "^1.0.5",
"vuex-mock-store": "0.0.7",
"wait-on": "^3.3.0"
what am i missing?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 22 (3 by maintainers)
We have the same problem here š¦
Iām facing a problem where the window.coverage is always coming āundefinedā even after following all the Cypress code coverage documentation steps with various instrumentation options mentioned⦠and when starting my server with the cmd
I get the following error
EvalError: Refused to evaluate a string as JavaScript because āunsafe-evalā is not an allowed source of script in the following Content Security Policy directive: "script-src āselfā āunsafe-inlineā
Appreciate your help on this @bahmutov
@elaco77 I have copied your example - you are not instrumenting your code, once you follow https://github.com/cypress-io/instrument-cra or https://github.com/bahmutov/testing-react#installation instructions your source code will be instrumented on the fly, and code coverage will be saved
The issue for me was during production build mode, I had to force my plugin to do instrumentation (vite-plugin-istanbul + forceBuildInstrumentation option).
@bahmutov hereās a repo where you can reproduce the issue. However I run the test, the nyc/out.json remains empty.
Feel free to contribute on the repo if you feel so. Also, let me know if thereās anything else I can do.
https://github.com/elaco77/cypress-code-coverage-showcase
I fixed this issue on our project (we using TypeScript) re-installing the dependencies and putting these codes:
package.json
.babelrc
added in plugins/index.js
module.exports:and support/index.ts
Itās works for now, but I can improve these.