Skip to content

Commit

Permalink
test: cover the case with the network error due to cy.visit() (#188)
Browse files Browse the repository at this point in the history
relates-to #105
  • Loading branch information
derevnjuk authored Feb 7, 2023
1 parent fbac2dd commit b5a0d6f
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions cypress/e2e/record-network-issues.cy.ts
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
});
});
});

0 comments on commit b5a0d6f

Please sign in to comment.