首页 > 解决方案 > 使用茉莉花进行窗口位置搜索的Angular 7模拟和返回值

问题描述

使用 Jasmine 对 Angular 7 进行单元测试。我需要window.location.search在 Jasmine 中设置值。

我尝试了以下场景。

window.location.search = '?param=part1' 
// It's not working. Browser reloaded or disconnected the unit test cases.

spyOnProperty(window.location, 'search').and.returnValue('?param=part1');
// Disconnected the unit test cases.

如何设置window.location.search值?

标签: javascriptangularjasminekarma-jasminespyon

解决方案


推荐阅读