cypress-io / cypress-io/code-coverage

Loading 'nyc' config broken with Cypress 10.x

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

Description

**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](https://github.com/cypress-io/code-coverage/releases) 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](https://github.com/istanbuljs/nyc#configuration-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](https://github.com/cypress-io/code-coverage/blob/3c280862861d00addb38f02e7b488e3aa24b75ca/task.js#L26) 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

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.