cypress: cy.visit('url', {headers: {}}) doesnt work per documentation
Current behavior:
cy.visit(options); in options if we pass headers like these it doesnt work with headless browser as well as --headed browser
options = {
url: 'www.localhost.com',
headers: {'a': 'b'}
};
Desired behavior:
above code should work as specified
Steps to reproduce:
try above code
Versions
OS: Mac Browsers Tried: Chrome 72/74, Electron (headless/headed) comes with cypress installation
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 25 (12 by maintainers)
is it possible to have a webex call i can walkthrough?or any meeting of your choice
Thank you I will try again and keep posted. Many thanks for your support
Not OP but yeah seems to be resolved and has the relevant info needed to help others in the future.
So I tried hunting this down and I think I did notice “something”. Say you have a local web app built at
localhost:3000/env/applicationand an api that gets called when visiting that url atlocalhost:3000/env/api/info/user. In order to display anything in the app when visiting/env/applicationthe headers need to be passed on to calls made to the api. In my particular case the headers were being passed to the url specified in the cy.visit() which waslocalhost:3000/env/applicationcall but not to the api calls. Not sure what that is about but you can get around behavior doing something like this:This allows you add request headers to network calls without forcing cypress to modify the response. Obviously edit the url glob pattern to whatever works for your app as that is just an example.