Mock/Stub the window.location.hostname et al #16332
Unanswered
kylane
asked this question in
Component Testing
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
HI guys - Im trying to mock/stub the window object (specifically window.location.hostname) as I have a component Im trying to test which has a condition for it on certain hostnames. I realise that cy.window() is a getter, not a setter - and trying to rename the hostname using cy.location() causes the websock to lose connection to the webpack dev server running on locahost.
I can do this in Jest using global (https://stackoverflow.com/questions/54021037/how-to-mock-window-location-href-with-jest-vuejs/57612297#57612297) but would be nice to be able to intercept/stub/mock the window object.
Any thoughts/suggestions?
Beta Was this translation helpful? Give feedback.
All reactions