Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 48cd348

Browse files
eulerssonjennifer-shehaneAtofStryker
authored
feat: add explicit check against codeCoverage.expectFrontendCoverageOnly before attempting to collect backend coverage (#555)
Co-authored-by: Jennifer Shehane <jennifer@cypress.io> Co-authored-by: AtofStryker <bglesias@gmail.com>
1 parent 2b78406 commit 48cd348

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

‎README.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,21 @@ After:
251251

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

254+
### expectFrontendCoverageOnly
255+
256+
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.
257+
258+
```json
259+
{
260+
"env": {
261+
"codeCoverage": {
262+
"url": "http://localhost:3003/__coverage__",
263+
"expectFrontendCoverageOnly": true
264+
}
265+
}
266+
}
267+
```
268+
254269
## Custom report folder
255270

256271
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:

‎support.js‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,19 @@ const registerHooks = () => {
178178
const baseUrl = Cypress.config('baseUrl') || cy.state('window').origin
179179
// @ts-ignore
180180
const runningEndToEndTests = baseUrl !== Cypress.config('proxyUrl')
181+
const expectFrontendCoverageOnly = Cypress._.get(
182+
Cypress.env('codeCoverage'),
183+
'expectFrontendCoverageOnly',
184+
false
185+
)
181186
const specType = Cypress._.get(Cypress.spec, 'specType', 'integration')
182187
const isIntegrationSpec = specType === 'integration'
183188

184-
if (runningEndToEndTests && isIntegrationSpec) {
189+
if (
190+
!expectFrontendCoverageOnly &&
191+
runningEndToEndTests &&
192+
isIntegrationSpec
193+
) {
185194
// we can only request server-side code coverage
186195
// if we are running end-to-end tests,
187196
// otherwise where do we send the request?

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /