From fb9c01a4d57d997ba220a83b59849e58874f0a04 Mon Sep 17 00:00:00 2001 From: Artem Derevnjuk Date: Tue, 7 Feb 2023 17:52:14 +0400 Subject: [PATCH] test: cover the case with the request issued by `cy.request()` relates-to #59 --- cypress/e2e/record-har.cy.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cypress/e2e/record-har.cy.ts b/cypress/e2e/record-har.cy.ts index be02cc2..68aa56c 100644 --- a/cypress/e2e/record-har.cy.ts +++ b/cypress/e2e/record-har.cy.ts @@ -41,6 +41,25 @@ describe('Record HAR', () => { }); }); + // ADHOC: cy.request() sends requests to actual endpoints, bypassing the interceptor + // For details please refer to the documentation at + // https://docs.cypress.io/api/commands/request#cyrequest-sends-requests-to-actual-endpoints-bypassing-those-defined-using-cyintercept + it.skip('records a request made by Cypress (not the tested app)', () => { + cy.recordHar(); + + cy.request('/api/products'); + + cy.saveHar({ waitForIdle: true }); + + cy.findHar() + .its('log.entries') + .should('contain.something.like', { + request: { + url: /\/api\/products$/ + } + }); + }); + // ADHOC: .mjs files are excluded as Cypress forces ts-node to use the 'commonjs' module format. Covered by unit tests. // For details please refer to https://github.com/cypress-io/cypress/blob/e6b2466f7b219a86da46c1ac720432ef75193ca4/packages/server/lib/plugins/child/ts_node.js#L25 ['.js', '.ts', '.cjs'].forEach(ext =>