cypress-io / cypress-io/code-coverage

Error: Code coverage tasks not registered by the plugins file

Open
#405 14 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
445
Forks
115
PR merge metrics
No merged PRs in 30d

Description

**Code-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**
```js
import '@cypress/code-coverage/support';
```

**In plugin index.js -->**
```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**
![Screenshot 2021-02-26 at 15 26 28](https://user-images.githubusercontent.com/46483554/109322937-30b94900-7853-11eb-8b7b-50102f7f963c.png)

tried adding this
```js
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

```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

```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
![Screenshot 2021-02-26 at 15 27 49](https://user-images.githubusercontent.com/46483554/109322983-3d3da180-7853-11eb-8a5d-3307b2a36f94.png)

- 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
![Screenshot 2021-02-26 at 16 58 21](https://user-images.githubusercontent.com/46483554/109323551-dec4f300-7853-11eb-9ded-6910eb84daa1.png)

- Do you have any custom NYC settings in `package.json` (`nyc` object) or in other [NYC config files](https://github.com/istanbuljs/nyc#configuration-files)
no

- Do you run Cypress tests in a Docker container?
not in this case

**Link to the repo**
Not a public repo.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.