我一直试图根据jest-enzyme设置官方指南,但Jest似乎没有注册jest-enzyme插件。
我已经缩略了下面的一些片段。
package.json
{
"scripts": {
"test": "jest"
},
"dependencies": {
"@emotion/core": "^10.0.27",
},
"devDependencies": {
"enzyme": "^3.11.0",
"jest": "^25.1.0",
"jest-emotion": "^10.0.27",
}
}jest.config.js
module.exports = {
// ...
snapshotSerializers: ['jest-emotion'],
// ...
}我还尝试在我的setupTests.js文件(配置酶的文件)中注册它,但是没有效果。
这是我运行测试时的终端输出。
# output
TypeError: expect(...).toHaveStyleRule is not a function
8 | const wrapper = mount(<Container />);
9 |
> 10 | expect(wrapper).toHaveStyleRule('max-width', '192rem');
| ^
11 | });
12 | });
13 |
at Object.toHaveStyleRule (__tests__/components/layout/container.test.jsx:10:19)发布于 2020-02-06 12:21:12
完全忽略了文档中关于定制匹配器的部分
https://stackoverflow.com/questions/60094161
复制相似问题