Default headers for cy.request command
See original GitHub issueCurrent behavior:
There is no possibility to add default headers for the cy.request
command. The only way to add such headers is to overwrite this command
Desired behavior:
The possibility to set default headers (and maybe some other default options) for the cy.request
command.
For example, we use SessionId
header for authenticated requests in our app. And I would like to implement custom login command for my tests, so it would set this header as default for all subsequent requests.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:18
- Comments:14 (1 by maintainers)
Top Results From Across the Web
request - Cypress Documentation
A request body to be sent in the request. Cypress sets the Accepts request header and serializes the response body by the encoding...
Read more >Network Requests | Cypress examples (v7.1.0) - Gleb Bahmutov
To make an XHR request, use the cy.request() command. // https://on.cypress.io/request ... From the response, you can get the individual headers.
Read more >How can I set my request headers in Cypress to avoid ...
When I set the request headers in options section Cypress ignores them and replaces with default ones. The example of my request:
Read more >How to Add Headers to Every Request in Cypress - Webtips
You can use cy.intercept in a beforeEach hook inside your support files to add extra headers to every request you make in Cypress....
Read more >Request - Cypress - W3cubDocs
Cypress sets the Accepts request header and serializes the response body by ... Pass in an options object to change the default behavior...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
👍 for this. Would like to also have the option to globally set headers for all cy.visit() requests.
As a workaround I overwrite
cy.request
method with my custom command:Please note it only works if you use
cy.request
withoptions
object.