相关疑难解决方法(0)

使用 Jest 运行测试库/react-native 时,RNEncryptedStorage 未定义

react-native-testing-library我正在尝试使用Jest设置我的反应本机测试环境。我的反应本机应用程序使用react-native-encrypted-storage. 当我运行第一个示例测试(下面的代码)时,它失败并提示RNEcryptedStorage未定义。

import React from "react";
import "react-native";
// Note: test renderer must be required after react-native.
import renderer from "react-test-renderer";
import App from "../App";
    
it("renders correctly", () => {
    console.log("Rendering");
    renderer.create(<App />);
});
Run Code Online (Sandbox Code Playgroud)

完整错误:

RNEncryptedStorage 未定义

在对象。(node_modules/react-native-encrypted-storage/lib/commonjs/EncryptedStorage.ts:7:9) 在对象处。(node_modules/react-native-encrypted-storage/lib/commonjs/index.ts:1:1)

这是我第一次设置测试环境,所以不确定从哪里开始解决这个问题。

jestjs react-native react-native-testing-library

5
推荐指数
2
解决办法
5376
查看次数