wait 方法报错

来源:6-10 完美组件 - SubMenu 组件添加测试

慕村3987014

2020-08-07

如图
图片描述
提示错误: TypeError: MutationObserver is not a constructor

写回答

2回答

张轩

2020-08-15

同学你好 试了一下 这是新版 CRA 的一个兼容问题,以后CRA 可能会在新版中解决这个问题。解决方案在这里

https://github.com/testing-library/dom-testing-library/issues/477#issuecomment-598606649

// 先安装一个插件
 npm install jest-environment-jsdom-sixteen --save-dev
 // package.json 中修改一下 scripts 中的 test 命令
 "test": "react-scripts test --env=jest-environment-jsdom-sixteen",

亲测有效 ?

0
1
慕村3987014
问题解决了,谢谢老师!
2020-08-15
共1条回复

张轩

2020-08-07

同学你好 上面那行黄字说明了具体情况, 在新版的 testing-library  wait 被 waitFor 取代掉了 ,你应该直接换成 waitFor 就可以了,详情可以参见黄字最后的那个网址。

0
6
慕村3987014
回复
张轩
已经上传到github了https://github.com/DeclanDeng/bottle-ui
2020-08-14
共6条回复

React18+TS高仿AntD从零到一打造组件库

设计,开发,测试,发布再到 CI/CD,从0到1造轮子

2122 学习 · 959 问题

查看课程