gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 20:51:11 24 4
gpt4 key购买 nike

如何测试这个,以获得 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com