cypress-io / cypress-io/code-coverage

Package.json settings are not read when cypress is in custom directory and uses '--project' flag

Open
#380 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
445
Forks
115
PR merge metrics
No merged PRs in 30d

Description

**Versions**

- What is this plugin's version?
3.9.1
- What is Cypress version?
6.1.2
- What is your operating system?
MacOs
- What is the Node version?
14
- What is the NPM version?
6
- How do you instrument your application?
Backend is instrumented with `nyc`, frontend with @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, it doesn't matter.
- 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?
That's part of the issue, the json file is in `test/ui/.nyc_output/out.json`.
- 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)
That's part of the issue, the custom NYC settings are not read from the main package.json file.
- Do you run Cypress tests in a Docker container?
No.

**Describe the bug**
When Cypress is run with `--project` flag and its main files are not in the project's root then replacing `coverage:report` command OR providing custom NYC config in the root `package.json` file doesn't work, Cypress doesn't use those.

After creating `package.json` in the directory where cypress directory is located (in my case it was `test/ui/package.json`), the custom `coverage:report` script works, however, the produced report shows 0% coverage as nyc wasn't able to find app files.

**Link to the repo**
I believe the description says clearly where's the issue. In case of any problems, I will try to create a reproducible example.

Related: https://github.com/cypress-io/code-coverage/issues/320

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.