Skip to content
This repository was archived by the owner on Sep 8, 2021. It is now read-only.

Commit 40dba32

Browse files
committed
Change test renderer to @testing-library/react-native
Run a test using @testing-library render.
1 parent 661fdb1 commit 40dba32

File tree

3 files changed

+665
-3
lines changed

3 files changed

+665
-3
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"android": "react-native run-android",
77
"ios": "react-native run-ios",
88
"start": "react-native start",
9+
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
910
"test": "jest",
10-
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
11+
"test:watch": "jest --watch"
1112
},
1213
"dependencies": {
1314
"@react-native-community/masked-view": "^0.1.7",

src/__tests__/App.test.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44

55
import 'react-native';
66
import React from 'react';
7+
import { render, toJSON } from '@testing-library/react-native';
8+
79
import App from '../App';
810

9-
// Note: test renderer must be required after react-native.
10-
import renderer from 'react-test-renderer';
11+
describe('<App />', () => {
12+
it('should render properly', () => {
13+
const { baseElement } = render(<App />);
14+
expect(toJSON(baseElement)).toMatchSnapshot();
15+
});
16+
});
17+
1118

1219
it('renders correctly', () => {
1320
renderer.create(<App />);

0 commit comments

Comments
 (0)