Я новичок, чтобы реагировать на нативный и пытаюсь писать примеры модульных тестов. Вот мой файл, для которого я пытаюсь написать пример модульных тестов
. js
/* eslint-disable no-use-before-define */
/* eslint-disable no-unused-vars */
import React, { memo } from 'react';
import { StyleSheet, View } from 'react-native';
import {
Container, Header, Body, Title, Content,
} from 'native-base';
const Layout = memo((props) => {
const { children } = props;
return (
<Container>
<Header>
<Body>
<Title>ToDo</Title>
</Body>
</Header>
<View style={styles.container}>
<Content style={styles.content}>
{children}
</Content>
</View>
</Container>
);
});
export default Layout;
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
content: {
width: 350,
},
});
Layout.test. js
import React from 'react';
import { shallow } from 'enzyme';
import { configure } from 'enzyme';
import __Layout from '../component/Layout';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
describe('ErrorAlert', () => {
it('should render ErrorAlert component', () => {
const wrapper = shallow(<__Layout />);
});
it('should render initial layout', () => {
// when
const component = shallow(<__Layout />);
// then
expect(component.getElements()).toMatchSnapshot();
});
});
`watchman watch-del /Users/Sandesh ; watchman watch-project /Users/Sandesh`
FAIL src/__test__/Layout.test.js
● Test suite failed to run
/Users/Sandesh/ToDoCRUD/node_modules/react-native/Libraries/Utilities/warnOnce.js:15
const warnedKeys: {[string]: boolean} = {};
^^^^^^^^^^
SyntaxError: Missing initializer in const declaration
at Runtime.createScriptFromCode (../.npm/_npx/31461/lib/node_modules/jest/node_modules/jest-runtime/build/index.js:1083:14)
at Object.<anonymous> (node_modules/react-native/Libraries/react-native/react-native-implementation.js:14:18)