Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cypress-io/code-coverage
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.13.12
Choose a base ref
...
head repository: cypress-io/code-coverage
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.14.0
Choose a head ref
  • 1 commit
  • 2 files changed
  • 3 contributors

Commits on Mar 25, 2025

  1. feat: add explicit check against codeCoverage.expectFrontendCoverageO…

    …nly before attempting to collect backend coverage (#555)
    
    Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
    Co-authored-by: AtofStryker <bglesias@gmail.com>
    3 people authored Mar 25, 2025
    Copy the full SHA
    48cd348 View commit details
Showing with 25 additions and 1 deletion.
  1. +15 −0 README.md
  2. +10 −1 support.js
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -251,6 +251,21 @@ After:

![Cypress knows to expect the backend code coverage only](./images/expect-backend.png)

### expectFrontendCoverageOnly

If there is ONLY frontend code coverage, set `expectFrontendCoverageOnly: true` in the `cypress.json` file. Otherwise, Cypress complains that it cannot find the frontend code coverage.

```json
{
"env": {
"codeCoverage": {
"url": "http://localhost:3003/__coverage__",
"expectFrontendCoverageOnly": true
}
}
}
```

## Custom report folder

You can specify a custom report folder by adding `nyc` object to the `package.json` file. For example, to save reports to `cypress-coverage` folder, use:
11 changes: 10 additions & 1 deletion support.js
Original file line number Diff line number Diff line change
@@ -178,10 +178,19 @@ const registerHooks = () => {
const baseUrl = Cypress.config('baseUrl') || cy.state('window').origin
// @ts-ignore
const runningEndToEndTests = baseUrl !== Cypress.config('proxyUrl')
const expectFrontendCoverageOnly = Cypress._.get(
Cypress.env('codeCoverage'),
'expectFrontendCoverageOnly',
false
)
const specType = Cypress._.get(Cypress.spec, 'specType', 'integration')
const isIntegrationSpec = specType === 'integration'

if (runningEndToEndTests && isIntegrationSpec) {
if (
!expectFrontendCoverageOnly &&
runningEndToEndTests &&
isIntegrationSpec
) {
// we can only request server-side code coverage
// if we are running end-to-end tests,
// otherwise where do we send the request?