【发布时间】:2019-12-11 20:30:30
【问题描述】:
我对 react-native-firebase 有一些问题,
我有一个 Windows 环境,我想使用 Jest 进行测试,
因此,当我运行 npm test 时,我得到 Test suite failed
因为我有一个 react-native-firebase 包,它应该集成在 IOS 中,我只是重命名文件 Android 并取消链接 react-native-firebase 以避免这些但它不适合我! 那么如果我没有 Mac,我该如何处理呢
测试代码
/**
* @format
* @lint-ignore-every XPLATJSCOPYRIGHT1
*/
import "react-native";
import React from "react";
import App from "../App";
import SignIn from "../src/screens/SignIn";
// Note: test renderer must be required after react-native.
import renderer from "react-test-renderer";
// it("renders correctly", () => {
// renderer.create(<App />);
// });
test("renders correctly", () => {
const tree = renderer.create(<SignIn />).toJSON();
expect(tree).toMatchSnapshot();
});
测试结果
FAIL __tests__/App.js
● Test suite failed to run
RNFirebase core module was not found natively on iOS, ensure you have correctly included the RNFirebase pod in your projects `Podfile` and have run `pod install`.
See http://invertase.link/ios for the ios setup guide.
at new Firebase (node_modules/react-native-firebase/dist/modules/core/firebase.js:28:13)
at Object.<anonymous> (node_modules/react-native-firebase/dist/modules/core/firebase.js:97:21)
at Object.<anonymous> (node_modules/react-native-firebase/dist/index.js:1:1)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 6.137s
Ran all test suites.
npm ERR! Test failed. See above for more details.
【问题讨论】:
-
抄送:@auticcat !
标签: reactjs unit-testing react-native jestjs react-native-firebase