rya*_*zec 9 javascript emotion reactjs jestjs enzyme
所以我开玩笑的快照可以正常工作,并使用babel 6 / emotion 9在快照中生成css和html,但是我需要更新为babel 7和情绪10,但是用酶的快照测试不再起作用。更新所需代码后,代码将编译并正常工作,只是测试被破坏了(迁移文档中没有任何内容显示与测试设置更新有关的任何内容)。
test('renders properly', () => {
// this works generating the correct css / html snapshot output
expect(renderer.create(<component.Template>test</component.Template>).toJSON()).toMatchSnapshot();
//this does not
const wrapper = shallow(<component.Template>test</component.Template>);
expect(toJson(wrapper)).toMatchSnapshot();
});
Run Code Online (Sandbox Code Playgroud)
酶版本生成以下输出:
exports[`renders properly 1`] = `
<ContextConsumer>
<Component />
</ContextConsumer>
`;
Run Code Online (Sandbox Code Playgroud)
我尝试通过将情感序列化器添加到snapshotSerializers
jest配置中并将其手动添加到setupFilesAfterEnv
脚本中来添加情感序列化器。
有人知道为什么我会得到这个输出吗?
小智 1
如果您已正确配置所有内容,请执行以下操作
test('renders properly', () => {
const wrapper = shallow(<component.Template>test</component.Template>);
expect(wrapper).toMatchSnapshot();
});
Run Code Online (Sandbox Code Playgroud)
这应该按预期工作。
归档时间: |
|
查看次数: |
242 次 |
最近记录: |