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.

Loading 'nyc' config broken with Cypress 10.x

See original GitHub issue

Logs and screenshots

Versions

  • What is this plugin’s version? latest
  • If the plugin worked before in version X, but stopped after upgrading to version Y, please try the released versions between X and Y to see where the breaking change was.
  • What is Cypress version? 10.4.0
  • What is your operating system? MacOS 12.5
  • What is the shell? bash
  • What is the Node version? 16.3.1
  • What is the NPM version? 8.3.2
  • How do you instrument your application? @cypress/instrument-cra
  • When running tests, if you open the web application in regular browser, and open DevTools, do you see window.__coverage__ object? Yes
  • 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?
  • Do you have any custom NYC settings in package.json (nyc object) or in other NYC config files. Yes, in package.json
  • Do you run Cypress tests in a Docker container? Yes, but issue is also seen locally, outside of Docker container

Describe the bug

This plugin no longer reads the ‘nyc’ config inside of {project root}/package.json. This appears to be due to changes in Cypress 10.0: now, the Cypress config file is loaded in a child process with cwd set to the parent dir of the config file, rather than the project root. That means that this code in this plugin will try to load {cypress config dir}/package.json (which doesn’t exist for me and probably many others) instead of the on at project root, like with Cypress 9.x.

https://github.com/cypress-io/cypress/issues/22689 has a few more details, including reproduction repo.

Link to the repo See https://github.com/cypress-io/cypress/issues/22689

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
shandavcommented, Sep 22, 2022

The workaround for creating a .nycrc in the root directory seems to be working for me, although it seems to be partially working. check-coverage: true seems to be picked up by Cypress, but the all: true option isn’t working for me (I’m trying to get coverage for source files that aren’t loaded during tests).

Not sure if this is the same issue, where it doesn’t see the all option, or if the all option isn’t working with my setup / Cypress.

This is my .nycrc file:

{
    "all": true,
    "extends": "@istanbuljs/nyc-config-typescript",
    "check-coverage": true
}
0reactions
thedaaroncommented, Sep 10, 2022

Can you also load nyc.config.cjs?

Read more comments on GitHub >

github_iconTop Results From Across the Web

config changes working directory, Cypress 9 -> 10/11/12 #22689
Current behavior In after:run task, Cypress 10 is using the ... Loading 'nyc' config broken with Cypress 10.x cypress-io/code-coverage#586.
Read more >
Cannot get code coverage with Cypress + Istanbul
It seems to be an issue in nyc when excludeAfterRemap is true. setting it to false fixed the problem.
Read more >
Parallelization | Cypress Documentation
During parallelization mode, Cypress Cloud interacts with your CI machines to orchestrate the parallelization of a test run via load-balancing of specs across ......
Read more >
package.json - rouch/Cypress - NotABug.org
Cypress - Fast, easy and reliable testing for anything that runs in a browser.
Read more >
cypress/code-coverage v3.10.0 - npm.io
By default it is false, which might let excluded files through. If you are excluding the files, and the instrumenter does not respect...
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