Jest React Native如何测试index.PLATFORM.js

时间:2017-08-31 15:32:39

标签: reactjs testing react-native tdd jest

如何测试,以获得100%的开玩笑覆盖率

// @flow
import { AppRegistry } from 'react-native'
import App from './src/App'


AppRegistry.registerComponent('app', () => App)

这类文件是'index.ios.js'和'index.android.js'

1 个答案:

答案 0 :(得分:0)

新的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 />
  );
});