我使用@ test -library/react-native来测试我的RN应用程序。当我运行yarn测试时,出现以下错误。@testing-library/react-native should have "jest-preset.js" or "jest-preset.json" file at the root.我的应用程序使
我有一个世博会项目,我想在其中使用挂钩。 在启动我的应用程序时,我得到了以下错误: TypeError: dispatcher.useState is not a function., 'dispatcher.useState' is undefined) 根据another well referenced issue中的建议,我已经更新了我的package.json以包括: "react编辑:删除了对react-dom的依赖,正如银翼男孩所指出的那样。
我在ReactNative中运行单元测试,这些单元测试需要模拟NativeEventEmitter和NativeModules,但将其他所有内容都保留为真正的代码。/node_modules/react-native/Libraries/TurboModule/TurboModuleRegistry.js:39:3)
at Object./node_modules/react-n
几天来,我尝试了许多方法来使用类型记录来设置@testing-library/react-native,但是仍然不能呈现一个简单的组件。粗略地说,我的堆栈是用类型记录来反应的,用ts-jest来开玩笑,用回反应-本机-测试-库。除其他外,我遵循这些准则:
ReferenceError: React is not definedimport React
在完全支持ESM的情况下运行Jest (现在可用!)以及使用the docs中所述的ts-jest的TypeScript。它工作得非常好!直到我尝试将其与ReactNative一起使用。在任何具有RN组件的测试中,我在node_modules/react-native/index.js中都会得到一个错误提示SyntaxError: Cannot use import state