Error: Code coverage tasks not registered by the plugins file
See original GitHub issueCode-coverge debug logs:
code-coverage combined NYC options { 'report-dir': './coverage', reporter: [ 'lcov', 'clover', 'json', 'json-summary' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ], excludeAfterRemap: false } +0ms
thats it and nothing else
Added in support --> index.js
import '@cypress/code-coverage/support';
In plugin index.js -->
const corePlugins = require('@company/e2e-core/plugins');
module.exports = function plugins(on, config) {
// eslint-disable-next-line global-require
require('@cypress/code-coverage/task')(on, config);
corePlugins(on, config);
return config;
};
Always get below error
tried adding this
require('@cypress/code-coverage/task')(on, config);
in e2e-core/plugins as well then it says
Warning: Multiple attempts to register the following task(s): resetCoverage, combineCoverage, coverageReport. Only the last attempt will be registered.
Versions Cypress 6.5.0 mac os catalina Node v15.8.0 NPM v7.5.3 Instrumentation: istanbul React application Code-coverage: 3.9.2 webpack-preprocessor: 5.6.0 cucumber-preprocessor: 4.0.1 Shell: xsh
We have e2e tests as feature files. Cypress is in the root where as application is as packages. We also have e2e-core package for cypress where there is also a common plugins file loaded onto cypress folder plugins–>index.js.
webpack.config.js
module.exports = {
node: { fs: 'empty', child_process: 'empty', readline: 'empty' },
module: {
rules: [
{
test: /\.js?$/,
exclude: [/node_modules/],
use: [{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ['istanbul'],
},
}],
},
{
test: /\.feature$/,
use: [
{
loader: 'cypress-cucumber-preprocessor/loader',
},
],
},
],
},
};
webpack index.js
const webpack = require('@cypress/webpack-preprocessor');
const webpackOptions = require('./webpack.config');
module.exports = function webpackPreprocessor(on) {
on('file:preprocessor', webpack({
webpackOptions,
}));
};
Instrumentation is setup. window.coverage works
-
Is there
.nyc_output
folder? Is there.nyc_output/out.json
file. Is it empty? Can you paste at least part of it so we can see the keys and file paths? no folder created -
Do you have any custom NYC settings in
package.json
(nyc
object) or in other NYC config files no -
Do you run Cypress tests in a Docker container? not in this case
Link to the repo Not a public repo.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:13
Top GitHub Comments
+1 to @jourdanrodrigues
I was debugging this for ages and ended up forking this repo and throwing errors every-which-way to find out why it wasn’t working. I eventually found that the tasks weren’t registered and “to fix this in config’s
setupNodeEvents
.”I made the following changes to fix this:
cypress.config.mjs
tocypress.config.cjs
(ESM to CJS).cypress/plugins/e2e.ts
.cypress.config.cjs
:In our case, the problem was that we were doing
config.env = process.env
, which I suppose must have been overwriting some value that@cypress/code-coverage
was setting. One way to fix it was to make sure that any existingconfig.env
values were still kept: