gpt4 book ai didi

jestjs - TypeError : (0 , _reactTestRenderer.act) 不是函数

转载 作者:行者123 更新时间:2023-12-02 18:07:44 24 4
gpt4 key购买 nike

我在测试用例中使用 renderHook 时遇到此错误。不确定是什么问题。

TypeError: (0 , _reactTestRenderer.act) is not a function

13 |
14 | it('allows to upload photos through the mutation', async () => {
> 15 | const { result, nextUpdate } = renderHook(() =>
| ^
16 | usePhotosUpload({
17 | photosUploadMutation,
18 | }),

at renderHook (../../../node_modules/react-hooks-testing-library/lib/index.js:151:30)
at Object._callee$ (__test__/hooks/usePhotosUpload.test.js:15:36)
at tryCatch (../../../node_modules/regenerator-runtime/runtime.js:62:40)
at Generator.invoke [as _invoke] (../../../node_modules/regenerator-runtime/runtime.js:296:22)
at Generator.prototype.(anonymous function) [as next] (../../../node_modules/regenerator-runtime/runtime.js:114:21)
at asyncGeneratorStep (__test__/hooks/usePhotosUpload.test.js:13:103)
at _next (__test__/hooks/usePhotosUpload.test.js:15:194)
at __test__/hooks/usePhotosUpload.test.js:15:364
at Object.<anonymous> (__test__/hooks/usePhotosUpload.test.js:15:97)

最佳答案

要解决此问题,请在您的 package.json 中使 react-test-renderer版本与 React 相同文件。

关于jestjs - TypeError : (0 , _reactTestRenderer.act) 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72914208/

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