cypress-io / cypress-io/code-coverage
Incomplete coverage caused by `filterSpecsFromCoverage`
- Dominant language
- TypeScript
- Stars
- 445
- Forks
- 115
- PR merge metrics
- No merged PRs in 30d
Description
**Versions**
- What is this plugin's version? 3.4.2 (but they all have the issue)
- What is your operating system? linux / mac (all fail)
- What is the shell? bash, zsh, all fail
- What is the Node version? 12
- What is the NPM version? 6
- How do you instrument your application? babel-istanbul-plugin
- When running tests, if you open the web application in regular browser, and open DevTools, do you see `window.__coverage__` object? Can you paste a screenshot? yes the coverage is correct at that point
**Describe the bug**
The function `filterSpecsFromCoverage` https://github.com/cypress-io/code-coverage/blob/master/support-utils.js#L9 can ignore files that are not spec when using a `testFiles` glob that is not the default `**/*.*`.
Let's say I have a glob `testFiles: "**/billing/*.js"` and my project has the following structure:
```
cypress
- integration
- billing
my-billing.spec.js
src
- billing
MyBill.js
```
Cypress runs the test my-billing.spec.js correctly but in the coverage report `MyBill.js` is not there.
This is because `filterSpecsFromCoverage` applies the `testFiles` glob to any file, even those that are not within the cypress integration folder so my `src/billing/MyBill.js` is filtered out.
**fix**
In my project I'm reverting to only use the default value of cypress `testFiles` but in this repo the fix seems pretty simple.
`filterSpecsFromCoverage` should only filter files that are in the integration folder
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.