← Back to library
Cypressnetworkintermediatev10+

Inject custom request headers

Modify outgoing requests to carry feature-flag or API-version headers.

1it('sends feature-flag header to enable new dashboard', () => {
2  cy.intercept('GET', '/api/**', (req) => {
3    req.headers['x-feature-flag'] = 'new-dashboard';
4    req.headers['x-api-version'] = '2';
5  });
6
7  cy.visit('/dashboard');
8  cy.get('[data-testid="new-dashboard-banner"]').should('be.visible');
9});
#headers#request#intercept#feature flag