Skip to content

feature: Allow multiple backend processes with urls config #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 30 additions & 20 deletions support.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,27 +160,37 @@ const registerHooks = () => {
// we can only request server-side code coverage
// if we are running end-to-end tests,
// otherwise where do we send the request?
const url = Cypress._.get(
Cypress.env('codeCoverage'),
'url',
'/__coverage__'
)
cy.request({
url,
log: false,
failOnStatusCode: false
})
.then(r => {
return Cypress._.get(r, 'body.coverage', null)
})
.then(coverage => {
if (!coverage) {
// we did not get code coverage - this is the
// original failed request
return
}
sendCoverage(coverage, 'backend')
const urls = Cypress._.get(Cypress.env('codeCoverage'), 'urls', [])
// If they didn't use urls config then grab single url config
if (urls.length == 0) {
const url = Cypress._.get(
Cypress.env('codeCoverage'),
'url',
'/__coverage__'
)
urls.push(url)
}
urls.map(url => {
logMessage(`Requesting coverage for **${url}**`)
cy.request({
url,
log: false,
failOnStatusCode: false
})
.then(r => {
return Cypress._.get(r, 'body.coverage', null)
})
.then(coverage => {
if (!coverage) {
// we did not get code coverage - this is the
// original failed request
logMessage(`No coverage for: **${url}**`)
return
}
sendCoverage(coverage, `backend: ${url}`)
})
})
logMessage('Finished collecting coverage')
}
})

Expand Down