diff --git a/cypress/e2e/record-har.cy.ts b/cypress/e2e/record-har.cy.ts index 4138ce2..be02cc2 100644 --- a/cypress/e2e/record-har.cy.ts +++ b/cypress/e2e/record-har.cy.ts @@ -1,9 +1,7 @@ import { Entry } from 'har-format'; describe('Record HAR', () => { - beforeEach(() => { - cy.visit('/'); - }); + beforeEach(() => cy.visit('/')); it('excludes a request by mime type', () => { cy.recordHar({ includeMimes: ['application/json'] }); @@ -21,6 +19,28 @@ describe('Record HAR', () => { }); }); + // ADHOC: Cypress will automatically attach this header at the network proxy level, outside of the browser. + // Therefore you will not see this header in the Dev Tools and the resulting HAR. + // For details please refer to the notice at https://docs.cypress.io/api/commands/visit#Add-basic-auth-headers + it.skip('records headers added by the proxy', () => { + cy.recordHar(); + + cy.visit('/', { auth: { password: 'admin', username: 'admin' } }); + + cy.saveHar({ waitForIdle: true }); + + cy.findHar() + .its('log.entries') + .should((data: Entry[]) => { + const expected = data.find(({ request }: Entry) => request.url === '/'); + const headers = expected?.request.headers ?? []; + expect(headers).to.contain.something.like({ + name: 'authorization', + value: /.+/ + }); + }); + }); + // 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 =>