col*_*r-j 6 jestjs enzyme apollo-client react-hooks
如何对使用钩子的功能组件进行单元测试(使用jest和) ?enzymeuseReactiveVar
我应该useReactiveVar用 来模拟钩子jest吗?
小智 4
您可以在每个测试中模拟整个 apollo 客户端以给出不同的响应。我是说:
jest.mock('@apollo/client', () => ({
makeVar: () => {
return {};
},
useReactiveVar: () => {
return { account: { name: 'Test' } };
},
}));
Run Code Online (Sandbox Code Playgroud)
但这仅在测试仅使用一个reactiveVar的组件时才有用。
| 归档时间: |
|
| 查看次数: |
2565 次 |
| 最近记录: |