Skip to content

Commit c4cedd8

Browse files
chore: CI validate react version tests (#1842)
1 parent e93af81 commit c4cedd8

File tree

5 files changed

+229
-10
lines changed

5 files changed

+229
-10
lines changed

.github/actions/setup-deps/action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
name: Setup deps
22
description: Setup Node.js and install dependencies
33

4+
inputs:
5+
react-version:
6+
description: React version to install (e.g., ^19.2.0)
7+
required: false
8+
react-native-version:
9+
description: React Native version to install (e.g., 0.83.1)
10+
required: false
11+
412
runs:
513
using: composite
614
steps:
@@ -25,3 +33,9 @@ runs:
2533
if: steps.yarn-cache.outputs.cache-hit != 'true'
2634
run: yarn install --immutable
2735
shell: bash
36+
37+
- name: Switch to React and React Native versions
38+
if: inputs.react-version != '' && inputs.react-native-version != ''
39+
run: |
40+
yarn add -D react@${{ inputs.react-version }} @types/react@${{ inputs.react-version }} react-native@${{ inputs.react-native-version }} @react-native/babel-preset@${{ inputs.react-native-version }}
41+
shell: bash

.github/workflows/ci.yml

Lines changed: 172 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,98 @@ jobs:
4343
- name: Typecheck
4444
run: yarn typecheck
4545

46-
typecheck-react-18:
46+
typecheck-rn-0-83-1:
4747
runs-on: ubuntu-latest
48-
name: Typecheck React 18
48+
name: Typecheck RN 0.83.1
4949
steps:
5050
- name: Checkout
5151
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5252

5353
- name: Setup Node.js and deps
54-
uses: ./.github/actions/setup-deps-react-18
54+
uses: ./.github/actions/setup-deps
55+
with:
56+
react-version: 19.2.0
57+
react-native-version: 0.83.1
58+
59+
- name: Typecheck
60+
run: yarn typecheck
61+
62+
typecheck-rn-0-82-1:
63+
runs-on: ubuntu-latest
64+
name: Typecheck RN 0.82.1
65+
steps:
66+
- name: Checkout
67+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
68+
69+
- name: Setup Node.js and deps
70+
uses: ./.github/actions/setup-deps
71+
with:
72+
react-version: 19.1.1
73+
react-native-version: 0.82.1
74+
75+
- name: Typecheck
76+
run: yarn typecheck
77+
78+
typecheck-rn-0-81-5:
79+
runs-on: ubuntu-latest
80+
name: Typecheck RN 0.81.5
81+
steps:
82+
- name: Checkout
83+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
84+
85+
- name: Setup Node.js and deps
86+
uses: ./.github/actions/setup-deps
87+
with:
88+
react-version: 19.1.0
89+
react-native-version: 0.81.5
90+
91+
- name: Typecheck
92+
run: yarn typecheck
93+
94+
typecheck-rn-0-80-2:
95+
runs-on: ubuntu-latest
96+
name: Typecheck RN 0.80.2
97+
steps:
98+
- name: Checkout
99+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
100+
101+
- name: Setup Node.js and deps
102+
uses: ./.github/actions/setup-deps
103+
with:
104+
react-version: 19.1.0
105+
react-native-version: 0.80.2
106+
107+
- name: Typecheck
108+
run: yarn typecheck
109+
110+
typecheck-rn-0-79-2:
111+
runs-on: ubuntu-latest
112+
name: Typecheck RN 0.79.2
113+
steps:
114+
- name: Checkout
115+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
116+
117+
- name: Setup Node.js and deps
118+
uses: ./.github/actions/setup-deps
119+
with:
120+
react-version: 19.0.0
121+
react-native-version: 0.79.2
122+
123+
- name: Typecheck
124+
run: yarn typecheck
125+
126+
typecheck-rn-0-78-3:
127+
runs-on: ubuntu-latest
128+
name: Typecheck RN 0.78.3
129+
steps:
130+
- name: Checkout
131+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
132+
133+
- name: Setup Node.js and deps
134+
uses: ./.github/actions/setup-deps
135+
with:
136+
react-version: 19.0.0
137+
react-native-version: 0.78.3
55138

56139
- name: Typecheck
57140
run: yarn typecheck
@@ -74,15 +157,98 @@ jobs:
74157
env:
75158
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
76159

77-
test-react-18:
160+
test-rn-0-83-1:
78161
runs-on: ubuntu-latest
79-
name: Test React 18
162+
name: Test RN 0.83.1
80163
steps:
81164
- name: Checkout
82165
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
83166

84167
- name: Setup Node.js and deps
85-
uses: ./.github/actions/setup-deps-react-18
168+
uses: ./.github/actions/setup-deps
169+
with:
170+
react-version: 19.2.0
171+
react-native-version: 0.83.1
172+
173+
- name: Test
174+
run: yarn test:ci
175+
176+
test-rn-0-82-1:
177+
runs-on: ubuntu-latest
178+
name: Test RN 0.82.1
179+
steps:
180+
- name: Checkout
181+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
182+
183+
- name: Setup Node.js and deps
184+
uses: ./.github/actions/setup-deps
185+
with:
186+
react-version: 19.1.1
187+
react-native-version: 0.82.1
188+
189+
- name: Test
190+
run: yarn test:ci
191+
192+
test-rn-0-81-5:
193+
runs-on: ubuntu-latest
194+
name: Test RN 0.81.5
195+
steps:
196+
- name: Checkout
197+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
198+
199+
- name: Setup Node.js and deps
200+
uses: ./.github/actions/setup-deps
201+
with:
202+
react-version: 19.1.0
203+
react-native-version: 0.81.5
204+
205+
- name: Test
206+
run: yarn test:ci
207+
208+
test-rn-0-80-2:
209+
runs-on: ubuntu-latest
210+
name: Test RN 0.80.2
211+
steps:
212+
- name: Checkout
213+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
214+
215+
- name: Setup Node.js and deps
216+
uses: ./.github/actions/setup-deps
217+
with:
218+
react-version: 19.1.0
219+
react-native-version: 0.80.2
220+
221+
- name: Test
222+
run: yarn test:ci
223+
224+
test-rn-0-79-2:
225+
runs-on: ubuntu-latest
226+
name: Test RN 0.79.2
227+
steps:
228+
- name: Checkout
229+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
230+
231+
- name: Setup Node.js and deps
232+
uses: ./.github/actions/setup-deps
233+
with:
234+
react-version: 19.0.0
235+
react-native-version: 0.79.2
236+
237+
- name: Test
238+
run: yarn test:ci
239+
240+
test-rn-0-78-3:
241+
runs-on: ubuntu-latest
242+
name: Test RN 0.78.3
243+
steps:
244+
- name: Checkout
245+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
246+
247+
- name: Setup Node.js and deps
248+
uses: ./.github/actions/setup-deps
249+
with:
250+
react-version: 19.0.0
251+
react-native-version: 0.78.3
86252

87253
- name: Test
88254
run: yarn test:ci

src/__tests__/react-native-api.test.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { FlatList, Image, Modal, ScrollView, Switch, Text, TextInput, View } fro
33

44
import { render, screen } from '..';
55
import { mapJsonProps } from '../test-utils/json';
6+
import { getReactNativeVersion } from '../test-utils/version';
67

78
/**
89
* Tests in this file are intended to give us an proactive warning that React Native behavior has
@@ -221,7 +222,23 @@ test('React Native API assumption: <Modal> renders a single host element', () =>
221222
</Modal>,
222223
);
223224

224-
expect(screen).toMatchInlineSnapshot(`
225+
const rnVersion = getReactNativeVersion();
226+
if (rnVersion.major == 0 && rnVersion.minor <= 79) {
227+
// eslint-disable-next-line jest/no-conditional-expect
228+
expect(screen).toMatchInlineSnapshot(`
229+
<Modal
230+
hardwareAccelerated={false}
231+
testID="test"
232+
visible={true}
233+
>
234+
<Text>
235+
Modal Content
236+
</Text>
237+
</Modal>
238+
`);
239+
} else {
240+
// eslint-disable-next-line jest/no-conditional-expect
241+
expect(screen).toMatchInlineSnapshot(`
225242
<Modal
226243
testID="test"
227244
>
@@ -230,6 +247,7 @@ test('React Native API assumption: <Modal> renders a single host element', () =>
230247
</Text>
231248
</Modal>
232249
`);
250+
}
233251
});
234252

235253
test('React Native API assumption: aria-* props render directly on host View', () => {

src/matchers/__tests__/to-be-disabled.test.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ test.each([
159159
['TouchableNativeFeedback', TouchableNativeFeedback],
160160
] as const)('toBeDisabled()/toBeEnabled() supports %s with "disabled" prop', (_, Component) => {
161161
render(
162-
// @ts-expect-error - JSX element type 'Component' does not have any construct or call signatures.
162+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
163+
// @ts-ignore - JSX element type 'Component' does not have any construct or call signatures.
163164
<Component disabled testID="subject">
164165
<Text>Button</Text>
165166
</Component>,
@@ -191,7 +192,8 @@ test.each([
191192
'toBeDisabled()/toBeEnabled() supports %s with "aria-disabled" prop',
192193
(_, Component) => {
193194
render(
194-
// @ts-expect-error - JSX element type 'Component' does not have any construct or call signatures.
195+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
196+
// @ts-ignore - JSX element type 'Component' does not have any construct or call signatures.
195197
<Component testID="subject" aria-disabled>
196198
<Text>Hello</Text>
197199
</Component>,
@@ -218,7 +220,8 @@ test.each([
218220
'toBeDisabled()/toBeEnabled() supports %s with "accessibilityState.disabled" prop',
219221
(_, Component) => {
220222
render(
221-
// @ts-expect-error - JSX element type 'Component' does not have any construct or call signatures.
223+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
224+
// @ts-ignore - JSX element type 'Component' does not have any construct or call signatures.
222225
<Component testID="subject" accessibilityState={{ disabled: true }}>
223226
<Text>Hello</Text>
224227
</Component>,

src/test-utils/version.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export interface Version {
2+
version: string;
3+
major: number;
4+
minor: number;
5+
patch: number;
6+
}
7+
8+
export function getReactNativeVersion(): Version {
9+
// eslint-disable-next-line @typescript-eslint/no-require-imports
10+
const version = require('react-native/package.json').version;
11+
const [major, minor, patch] = version.split('.');
12+
return {
13+
version,
14+
major: Number(major),
15+
minor: Number(minor),
16+
patch: Number(patch),
17+
};
18+
}

0 commit comments

Comments
 (0)