javascript - 使用茉莉花进行窗口位置搜索的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
值?
解决方案
推荐阅读
- python - setuptools中有卸载命令吗?
- php - Laravel FFMpeg - 无法在文件错误中加载 FFMpeg
- node.js - 如何在firebase firestore中存储列表?
- python - 如何为初学者在神经网络中使用 RandomSearchCV 或 GridSearchCV 优化超参数?
- arrays - 在函数 (C) 中用作数组的指针
- javascript - 如何从javascript对象键在网页上显示图像
- angular - 如何在角度 6 中使用 *ngFor 绑定对象数组
- scip - 为什么 scip 在调用 SCIPincludeBranchRrule 后做出额外的分支决定?
- html - 使用 CSS 在 HTML 表格中堆叠元素
- python - 我在使用 numpy 和 openCV 时遇到问题