Skip to content

Commit 10e69c5

Browse files
Add support for testing with react@17 (#1115)
* Add support for testing with react@17 * Test with react@17 through a script updating dependencies * Use test:ci command also for react@17 * Minor adjustements to script * Update scripts/test_react_17 Co-authored-by: Maciej Jastrzebski <[email protected]>
1 parent fbf3e78 commit 10e69c5

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

.circleci/config.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ jobs:
5858
- store_artifacts:
5959
path: coverage
6060
destination: coverage
61+
test:react:17:
62+
<<: *defaults
63+
steps:
64+
- attach_workspace:
65+
at: ~/react-native-testing-library
66+
- run: |
67+
yarn test:ci:react:17
6168
test-website:
6269
<<: *defaults
6370
steps:
@@ -91,6 +98,9 @@ workflows:
9198
- tests:
9299
requires:
93100
- install-dependencies
101+
- test:react:17:
102+
requires:
103+
- install-dependencies
94104
- test-website:
95105
requires:
96106
- install-dependencies

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"clean": "del build",
7373
"test": "jest",
7474
"test:ci": "jest --maxWorkers=2",
75+
"test:ci:react:17": "scripts/test_react_17",
7576
"typecheck": "tsc",
7677
"flow": "flow",
7778
"copy-flowtypes": "cp typings/index.flow.js build",

scripts/test_react_17

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
cp yarn.lock yarn.lock.backup
4+
cp package.json package.json.backup
5+
6+
7+
yarn test:ci
8+
9+
mv package.json.backup package.json
10+
mv yarn.lock.backup yarn.lock
11+
12+
yarn --ignore-scripts

src/__tests__/render.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ test('debug changing component', () => {
205205
test('renders options.wrapper around node', () => {
206206
type WrapperComponentProps = { children: React.ReactNode };
207207
const WrapperComponent = ({ children }: WrapperComponentProps) => (
208-
<SafeAreaView testID="wrapper">{children}</SafeAreaView>
208+
<View testID="wrapper">{children}</View>
209209
);
210210

211211
const { toJSON, getByTestId } = render(<View testID="inner" />, {
@@ -214,20 +214,20 @@ test('renders options.wrapper around node', () => {
214214

215215
expect(getByTestId('wrapper')).toBeTruthy();
216216
expect(toJSON()).toMatchInlineSnapshot(`
217-
<RCTSafeAreaView
217+
<View
218218
testID="wrapper"
219219
>
220220
<View
221221
testID="inner"
222222
/>
223-
</RCTSafeAreaView>
223+
</View>
224224
`);
225225
});
226226

227227
test('renders options.wrapper around updated node', () => {
228228
type WrapperComponentProps = { children: React.ReactNode };
229229
const WrapperComponent = ({ children }: WrapperComponentProps) => (
230-
<SafeAreaView testID="wrapper">{children}</SafeAreaView>
230+
<View testID="wrapper">{children}</View>
231231
);
232232

233233
const { toJSON, getByTestId, rerender } = render(<View testID="inner" />, {
@@ -240,15 +240,15 @@ test('renders options.wrapper around updated node', () => {
240240

241241
expect(getByTestId('wrapper')).toBeTruthy();
242242
expect(toJSON()).toMatchInlineSnapshot(`
243-
<RCTSafeAreaView
243+
<View
244244
testID="wrapper"
245245
>
246246
<View
247247
accessibilityHint="test"
248248
accessibilityLabel="test"
249249
testID="inner"
250250
/>
251-
</RCTSafeAreaView>
251+
</View>
252252
`);
253253
});
254254

0 commit comments

Comments
 (0)