Skip to content

Commit

Permalink
test: cover the case with the headers attached at the proxy level
Browse files Browse the repository at this point in the history
relates-to #83
  • Loading branch information
derevnjuk committed Feb 7, 2023
1 parent 6688e1f commit 3757194
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions cypress/e2e/record-har.cy.ts
Original file line number Diff line number Diff line change
@@ -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'] });
Expand All @@ -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 =>
Expand Down

0 comments on commit 3757194

Please sign in to comment.