I am trying to add a request header to every api request generated in Cypress. I have a version that works using cy.server
but this is being depricated, so I am trying to replace it with cy.intercept
. I don't see any errors when I run this code, but I don't see the header added to my requests either:
beforeEach(() => {
cy.intercept('*',(req) => {
console.log('MATCHED INTERCEPT')
req.headers['my-test'] = 'TEST'
})
})
I can see the log text 'MATCHED INTERCEPT' in the console, so I know that the intercept is matching something....
Can anyone tell me what is wrong with this code?
I think you will not be able to see the new header after intercepting, as per their documentation :
Hope this was useful
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With