Skip to content

MockRoute() not working for overrides Headers on specific URL #3291

@Horsty80

Description

@Horsty80

What are you trying to achieve?

I try to overrides headers for specific routes.
I know I.haveRequestHeaders() is working but on all routes, i need to overrides only specific routes that match RegExp

// Works on all routes
I.haveRequestHeaders({ 'X-Custom-Header': 'My-custom-Value' }); 

// Doesn't works 
I.mockRoute(/\/api\//i, async (route: Route) => {
  const existingHeaders = await route.request().allHeaders();
  const headers = {
    ...existingHeaders,
    'X-Custom-Header': 'My-custom-Value',
  };
  route.continue({ headers });
});
// Headers are not modified

Details

  • CodeceptJS version: "codeceptjs": "^3.3.0",
  • NodeJS Version: v16.9.1
  • Playwright: "playwright": "^1.20.2"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions