如何测试这个,以获得 100% 的 Jest 覆盖率
// @flow
import { AppRegistry } from 'react-native'
import App from './src/App'
AppRegistry.registerComponent('app', () => App)
这种文件是'index.ios.js'和'index.android.js'
最佳答案
新安装的 React Native 附带的默认测试应该可以满足您的需求。
import 'react-native';
import React from 'react';
import Index from './index.PLATFORM.js';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('renders correctly', () => {
const tree = renderer.create(
<Index />
);
});
关于reactjs - Jest React Native 如何测试 index.PLATFORM.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45985221/