gpt4 book ai didi

javascript - Jest 快照为每个测试文件返回相同的代码

转载 作者:行者123 更新时间:2023-11-29 23:00:58 25 4
gpt4 key购买 nike

我正在运行带有快照的 Jest enzyme 测试。快照文件生成正确,但它们的内容基本上是:

// Jest Snapshot v1, https;//link
exports[`Component1 should match snapshot 1`] = `ReactWrapper {}`;
^^^^^^^^ <-- only component name is changing

对于每一个被测文件,即使被测文件逻辑复杂,代码400+行。

为什么会这样?完整代码在哪里?

it('should match snapshot', () => {
const component = mount(<Component1 />);

expect(component).toMatchSnapshot();
});

最佳答案

我正在查看我自己的测试,似乎需要 enzyme-to-json 包来使用 Jest 创建有用的快照。这将序列化您的数据以用于 Jest。

关于javascript - Jest 快照为每个测试文件返回相同的代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55651850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com