Skip to content

Error: Code coverage tasks not registered by the plugins fileΒ #405

Open
@srilakshmishankar

Description

@srilakshmishankar

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

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
Screenshot 2021-02-26 at 15 26 28

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
Screenshot 2021-02-26 at 15 27 49

  • 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

  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions