腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(9999+)
视频
沙龙
1
回答
Jest
JSDom
中
未
实现
window.location.assign
()
、
、
我有这个功能
window.location.assign
(url) 这在
jsdom
中
是不存在的。所以在我的测试
中
引发了一个错误 有人提到了存根这个函数的可能性(使用Sinon) see
jsdom
issue sinon.stub(window.location, 'assign'); expect(
window.location.assign
).to.have.been.calledWith(url); 我如何使用
Jest
复制它?
浏览 12
提问于2019-01-06
得票数 0
回答已采纳
3
回答
使用
jest
.js截取导航更改(或如何覆盖和恢复location.href)
、
、
、
在
jsdom
上使用
jest
,我尝试通过使用
jest
模拟函数覆盖location.href设置器来做到这一点,并且它是有效的。originalLocationHref = Object.getOwnPropertyDescriptor(window.location, 'href'); // returns undefined spyFn =
jest
.fn
浏览 1
提问于2017-09-12
得票数 22
2
回答
Jest
spyOn与模拟-包括定义错误和未定义错误
、
刚升级到
jsdom
-14在我的玩笑配置。它运行得很好,但是一个测试失败了。test('Do the thing', () => {});然而..。我也不能做一个
jest
.spyOn,这似乎是建议的。我以前没有使用过spyOn。
jest
.spyOn(<em
浏览 1
提问于2019-07-25
得票数 0
回答已采纳
7
回答
如何修复错误:
未
实现
:导航(哈希更改除外)
、
、
、
我正在为包含window.location.href的文件
实现
单元测试,我需要检查它。console.error node_modules/
jsdom
/lib/
jsdom
/virtual-console.js:29 Error更新--我深入研究了源代码,我认为这个错误来自
jsdom
。at module.exports (webapp
浏览 0
提问于2019-01-08
得票数 66
回答已采纳
2
回答
如何使用
Jest
在Vuejs应用程序上spyOn
window.location.assign
?
、
、
我需要spyOn
window.location.assign
来进行我的单元测试。但是当我运行测试时,我得到了这个错误。Cannot spy the assign property because it is not a function; undefined given instead
jest
.spyOn
浏览 4
提问于2019-01-11
得票数 4
3
回答
设置或赋值“window.location”时开玩笑
、
、
、
、
我将
Jest
库升级到v25,所有检查位置更改的单元测试都失败了。我认为,对于更改位置,
jsdom
窗口对象不应该再被视为真正的浏览器窗口。我的发现:
window.location.assign
浏览 17
提问于2020-01-28
得票数 7
回答已采纳
2
回答
如何正确地模拟DOM,以便能够使用使用Xterm.js的
Jest
测试Vue应用程序?
、
、
、
、
mount } from '@vue/test-utils'; const wrapper = mount(App);当我在这个测试文件上运行
jest
rendering context" // error that
Jest
浏览 3
提问于2019-06-04
得票数 5
回答已采纳
3
回答
考虑使用"
jsdom
“测试环境。
、
、
、
crashing', () => { })我有一个包含以下内容的
jest
.config.jsonsetupFilesAfterEnv": [ ]在我的setupTests.ts上 import '@testi
浏览 6
提问于2021-09-17
得票数 57
回答已采纳
1
回答
与Nuxt和
Jest
的集成测试
、
、
homePage = await nuxt.renderAndGetWindow('http://localhost:3001/');这给了我两个截然不同的错误: node_modules/
jest
-jasmine2/build/jasmine/Env.js:158 Type
浏览 0
提问于2018-09-25
得票数 1
1
回答
开玩笑不能处理insertAdjacentElement吗?
、
、
beforeend', spinner);}这是
Jest
中
的一个错误还是我在这里遗漏了什么?
浏览 18
提问于2017-08-23
得票数 9
回答已采纳
1
回答
如何为@Inject( Document )文档创建单元测试:以角表示的文档
、
cancel() {}...错误:
未
实现
:在(C:\Desenvolvimento\Quero-Receber-PDPJ\pdpj-fed-account-rece
浏览 3
提问于2021-02-09
得票数 1
回答已采纳
1
回答
试验反应.使用反应的热键.试验.程序库
、
、
、
、
bubbles: true }); waitForElement(() => getByText('Enter clicked'));});/* global
jest
*/import '
jest
-localstorage-mock'; import dotenvfrom
浏览 0
提问于2018-12-21
得票数 3
回答已采纳
3
回答
Jest
测试文件
中
的模拟文档
、
、
、
api.js'; })(document, 'script', 'google-recaptcha');在
Jest
测试文件
中
模拟document有问题,因为d只有Document { location: [Getter/Setter] },因此其他对象是undefined。我尝试在
Jest
中
添加setupFiles,作为: "setupFiles":
浏览 27
提问于2017-10-09
得票数 1
回答已采纳
3
回答
ag-grid
Jest
测试- this.btFirst.insertAdjacentElement不是一个函数
、
、
、
我尝试使用
Jest
测试ag-grid组件: it('includes class names
浏览 0
提问于2019-11-02
得票数 5
1
回答
如何使用
Jest
模拟"window.screen.orientation.lock“函数?
、
、
、
、
在AppComponent
中
,我们有一个锁定屏幕方向的代码。为此,我们使用window.screen.orientation.lock函数。如何使用
Jest
来模拟上述功能?
浏览 0
提问于2019-04-29
得票数 1
回答已采纳
2
回答
添加和执行脚本react-
jest
library和
jest
、
、
在调用render之前,我正尝试通过以下方式将脚本添加到我的文档
中
。当您没有npm包,并且需要包含自定义脚本时,如何配置这些脚本以在您的react- test -library
jest
测试
中
运行?
浏览 40
提问于2020-03-05
得票数 3
1
回答
将
Jest
升级到v29 - Error测试环境
jest
- environment -
jsdom
无法找到
、
、
、
、
是否有人成功升级到最新的
Jest
版本29?Error: Test environment
jest
-environment-
jsdom
cannot be found.
浏览 13
提问于2022-04-26
得票数 63
回答已采纳
1
回答
浏览器历史记录在我的测试
中
需要一个DOM
、
、
、
、
当我尝试测试我的sagas时,我会得到以下错误: 之所以会发生这种情况,是因为我在sagas中使用了函数redirectTo(),这个函数从这个文件导出: history.push(path);我该
浏览 2
提问于2021-10-11
得票数 1
4
回答
ReferenceError:未定义customElements
、
、
、
、
我正在使用@angular@9.0.7, (与
Jest
一起使用),在一个项目中使用,当我运行ng serve甚至ng build时,所有东西都在应用程序上工作,但是当我尝试为使用Inputmask的@Pipe: '1111-1', }@Spec >
浏览 3
提问于2020-03-19
得票数 11
回答已采纳
1
回答
在StencilJS测试中使用
jest
-dom会抛出错误
、
、
我在使用的
jest
匹配器的StencilJS中进行了一个单元测试。Right-hand side of 'instanceof' is not an object at Object.toHaveFormValues (node_modules/@testing-library/
jest<
浏览 28
提问于2020-11-13
得票数 1
点击加载更多
相关
资讯
在Django中实现一个高性能未读消息计数器
使用Jest测试原生TypeScript项目
利用 Jest为React 组件编写单元测试
NPM酷库:jsdom,纯JS实现的DOM
React 16 Jest手动模拟
热门
标签
更多标签
云服务器
ICP备案
对象存储
云点播
实时音视频
活动推荐
运营活动
广告
关闭
领券