-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: cover the case with the network error due to
cy.visit()
(#188)
relates-to #105
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
describe('Record network issues', () => { | ||
const url = 'https://unknown-non-well-defined-host.cypress.test.org'; | ||
|
||
beforeEach(() => { | ||
cy.once('fail', () => false); | ||
cy.intercept(url).as('err'); | ||
}); | ||
|
||
afterEach(() => { | ||
cy.wait('@err').its('error.code').should('eq', 'ENOTFOUND'); | ||
|
||
cy.saveHar({ waitForIdle: true }); | ||
|
||
cy.findHar().its('log.entries').should('contain.something.like', { | ||
request: { | ||
url | ||
} | ||
}); | ||
}); | ||
|
||
// ADHOC: Normally, a request with an error should be included, | ||
// but the cy.visit() fails ahead of time due to a resolving mechanism in Cypress. | ||
// For details please follow the code at | ||
// https://github.com/cypress-io/cypress/blob/fc43cecdadda62521f6167e16b48ebc37ccc858a/packages/driver/src/cy/commands/navigation.ts#L464 | ||
it.skip('records a request failed due DNS issues', () => { | ||
cy.recordHar(); | ||
|
||
cy.visit(url, { | ||
failOnStatusCode: false, | ||
retryOnNetworkFailure: false | ||
}); | ||
}); | ||
}); |