开玩笑检查窗口属性已更改

时间:2020-06-03 12:38:06

标签: reactjs jestjs enzyme react-testing-library

我在代码中包含以下行:

window.parent.location.href = someCalculatedVal     

在测试中,我想验证window.parent.location.href的值正确

此行expect(window.parent.location.href).toEqual(DOMAIN + "/failureUrl");无效:

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

我看起来好像它需要运行的窗口而不是实际的窗口,

0 个答案:

没有答案