0

I have in the code this line:

window.parent.location.href = someCalculatedVal     

In the test I want to verify that window.parent.location.href has the correct value

This line expect(window.parent.location.href).toEqual(DOMAIN + "/failureUrl"); is not working:

Error: expect(received).toEqual(expected) // deep equality
Expected: "http://www.example.com/failureUrl"
Received: "http://localhost/" 

I'ts look like it takes the running window and not the real window,

cheziHoyzer
  • 4,803
  • 12
  • 54
  • 81
  • Usually you should use `global` instead of `window` in jest tests. For more help please post your component code in charge of `window.parent.location.href = someCalculatedVal` and your failing test. – aquinq Jun 04 '20 at 17:52
  • this seems similar to https://stackoverflow.com/questions/50977862/how-to-test-url-change-with-jest#51334009 – intmarinoreturn0 Jul 24 '20 at 06:04

0 Answers0