question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support should not send coverage unless plugins task has been registered

See original GitHub issue

in a situation where a support file has been registered BUT there is no task in the plugins file, we should not try to call the coverage report task

Example situation

{
  "pluginsFile": false,
  "supportFile": "node_modules/cypress-react-unit-test/support"
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
gwvtcommented, May 8, 2022

How do you keep the coverage tasks registered when using multiple config files as documented at https://docs.cypress.io/api/plugins/configuration-api#Customize-available-browsers?

In plugins/index.js as documented there:

module.exports = (on, config) => {
  const environment = config.env.configFile || "development";
  const configurationForEnvironment = fetchConfigurationByFile(environment);

  return configurationForEnvironment || config;
};

How do you incorporate

  require('@cypress/code-coverage/task')(on, config);

to register the coverage tasks on the returned config object? Config by file works but without coverage. Coverage works without config by file (i.e., just returning config). I can’t get both to work together…

3reactions
CharlesStovercommented, Dec 21, 2021

Is it possible for this to throw an error? I’ve been debugging for days why I’m not getting any coverage files in my CI workflow. Local tests didn’t give me anything either, and this warning was simply not visible: image It was sheer happenstance that I ran a one-liner test on a local Cypress instance and saw this banner.

The end problem was that my plugins file’s default export wasn’t returning config after I mutated it with @cypress/code-coverage:

import task from '@cypress/code-coverage';
export default function(on, config) {
  task(on, config);
  return config; // <-- REQUIRED
}

This would have been so much easier to debug if CI had failed with an error that the code coverage task had not registered instead of failing silently.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - How to register cypress `code-coverage` plugin ...
From your description the only step missing is the support file import. // cypress/support/e2e.js import '@cypress/code-coverage/support'.
Read more >
@cypress/code-coverage - npm
This plugin DOES NOT instrument your code. ... If your application has been instrumented correctly, then you should see additional counters ...
Read more >
Migration Guide | Cypress Documentation
Migrating to Cypress 12.0 This guide details the changes and how to change your code to migrate to Cypress version 12.0.
Read more >
Java test coverage - SonarQube Documentation
SonarQube supports the reporting of test coverage as part of the analysis of your Java project. However, SonarQube does not generate the coverage...
Read more >
JUnit 5 User Guide
However, you can still test code that has been compiled with ... Unlike JUnit 4's @Test annotation, this annotation does not declare any ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found