带有笑话/酶或React-Native-Testing-Library的单元测试对于导入问题永远不会达到代码覆盖率的100%,如果不采取其他导入,则某些导入显示警告IEEIEIE
这些模块位于node_modules中(并且node_modules被包括在coveragePathIgnorePatterns中,并且不包含在collectCoverageFrom中)或自定义模块,甚至没有if / else语句
import React from 'react';
import { cleanup, render } from 'react-native-testing-library';
import ItemListaComprobante from './ItemListaComprobante';
describe('test container ConfiguracionPin', () => {
let wrapper;
const props = {
label: 'Test',
value: 'Test',
};
afterEach(() => cleanup);
beforeEach(() => {
wrapper = render(<ItemListaComprobante {...props} />);
});
test('test container ConfiguracionPin render properly ', () => {
expect(wrapper).toMatchSnapshot();
});
});
import React, { memo } from 'react';
import { Text } from 'react-native'; // (without IEEI)
import PropTypes from 'prop-types';
import { // IEEI
Left,
Right,
CardItem,
} from 'native-base';
const propTypes = {
label: PropTypes.string.isRequired,
value: PropTypes.string.isRequired,
};
const ItemListaComprobante = ({ label, value }) => (
<CardItem
bordered
borderedWhite
>
<Left>
<Text>{label}</Text>
</Left>
<Right>
<Text
bold
numberOfLines={1}
ellipsizeMode="tail"
>
{value}
</Text>
</Right>
</CardItem>
);
ItemListaComprobante.propTypes = propTypes;
export default memo(ItemListaComprobante);
我的玩笑设置
module.exports = {
verbose: true,
preset: 'react-native',
testEnvironment: 'jsdom',
transform: { '^.+\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js' },
setupFiles: ['<rootDir>/jest.setup.js'],
transformIgnorePatterns: ['/node_modules/*.js'],
coveragePathIgnorePatterns: [
'<rootDir>/index.js',
'<rootDir>/App.js',
'<rootDir>/commitlint.config.js',
'/node_modules/',
'jest.setup.js',
'ReactotronConfig.js',
'LogUtils.js',
'jest.config.js',
'rn-cli.config.js',
'transformer.js',
'super-wallet/coverage/lcov-report',
'Str.js',
],
setupFilesAfterEnv: [
'<rootDir>/__mocks__/react-native-camera.js',
'<rootDir>/__mocks__/react-native-fetch-blob.js',
'<rootDir>/__mocks__/react-native-firebase.js',
'<rootDir>/__mocks__/react-navigation.js',
'<rootDir>/__mocks__/react-native-reactotron.js',
'<rootDir>/__mocks__/react-native-user-agent.js',
'<rootDir>/__mocks__/osiris.js',
'<rootDir>/__mocks__/react-native-check-app-install.js',
'<rootDir>/__mocks__/react-native-image-crop-picker.js',
'<rootDir>/__mocks__/react-native-app-link.js',
],
collectCoverageFrom: ['**/*.{js,jsx}', '!**/node_modules/**', '!**/vendor/**'],
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: -10,
},
},
};
我的babelrc设置
{
"presets": ["module:metro-react-native-babel-preset"]
}
如果有人可以帮助我,我将不胜感激,我查看了有关开胃菜/伊斯坦布尔和酵素的文档,但我什么也没看到,即使在这里我也进行了搜索,以防有人遇到与我相同的问题
这是伊斯坦布尔报道中的错误
答案 0 :(得分:0)
我们需要您遇到的错误的屏幕截图。