Skip to content

Commit d1ee96d

Browse files
committed
test gate react 19.2
1 parent ceab9c9 commit d1ee96d

4 files changed

Lines changed: 51 additions & 7 deletions

File tree

.github/workflows/nightly.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,20 @@ jobs:
7272
strategy:
7373
fail-fast: false
7474
matrix:
75-
rn-lane: ['0.85.0', '0.84.1', '0.83.4', '0.82.1', '0.81.6', '0.80.3', '0.79.7', '0.78.3', latest, next, nightly]
75+
rn-lane:
76+
[
77+
'0.85.0',
78+
'0.84.1',
79+
'0.83.4',
80+
'0.82.1',
81+
'0.81.6',
82+
'0.80.3',
83+
'0.79.7',
84+
'0.78.3',
85+
latest,
86+
next,
87+
nightly,
88+
]
7689
test-renderer-version: ['1.0.0', '1.1.0', '1.2.0']
7790
include:
7891
- rn-lane: '0.85.0'

eslint.config.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import tseslint from 'typescript-eslint';
22
import callstackConfig from '@callstack/eslint-config/react-native.flat.js';
33
import { fixupPluginRules } from '@eslint/compat';
4+
import pluginJest from 'eslint-plugin-jest';
45
import simpleImportSort from 'eslint-plugin-simple-import-sort';
56

7+
const additionalTestBlockFunctions = ['testGateReact19_2', 'testGateReact19_3'];
8+
69
const patchedCallstackConfig = callstackConfig.map((configItem) => {
710
if (!configItem.plugins?.react) {
811
return configItem;
@@ -45,6 +48,9 @@ export default [
4548
},
4649
{
4750
files: ['**/*.test.{ts,tsx}', 'src/test-utils/**'],
51+
plugins: {
52+
jest: pluginJest,
53+
},
4854
rules: {
4955
'react/no-multi-comp': 'off',
5056
'react-native/no-color-literals': 'off',
@@ -54,6 +60,9 @@ export default [
5460
'react-native-a11y/has-valid-accessibility-ignores-invert-colors': 'off',
5561
'react-native-a11y/has-valid-accessibility-value': 'off',
5662
'@typescript-eslint/no-explicit-any': 'off',
63+
'jest/expect-expect': ['error', { additionalTestBlockFunctions }],
64+
'jest/no-standalone-expect': ['error', { additionalTestBlockFunctions }],
65+
'jest/prefer-ending-with-an-expect': ['error', { additionalTestBlockFunctions }],
5766
},
5867
},
5968
];

src/__tests__/render.test.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Text, View } from 'react-native';
33

44
import { render, screen } from '..';
55
import { _console, logger } from '../helpers/logger';
6+
import { testGateReact19_2 } from '../test-utils/react-version-gates';
67

78
function MaybeSuspend({
89
children,
@@ -112,7 +113,7 @@ describe('render options', () => {
112113
});
113114

114115
describe('hidden instance props', () => {
115-
test('renders Activity hidden and then visible', async () => {
116+
testGateReact19_2('renders Activity hidden and then visible', async () => {
116117
await render(
117118
<React.Activity mode="hidden">
118119
<View testID="activity-target">
@@ -122,11 +123,11 @@ describe('hidden instance props', () => {
122123
);
123124

124125
expect(screen.queryByTestId('activity-target')).not.toBeOnTheScreen();
125-
expect(screen.getByTestId('activity-target', { includeHiddenElements: true }).props.style).toEqual(
126-
{
127-
display: 'none',
128-
},
129-
);
126+
expect(
127+
screen.getByTestId('activity-target', { includeHiddenElements: true }).props.style,
128+
).toEqual({
129+
display: 'none',
130+
});
130131
expect(screen.toJSON()).toMatchInlineSnapshot(`
131132
<View
132133
style={
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
3+
function isReactMinorOrNewer(targetMinor: number): boolean {
4+
const match = /^(\d+)\.(\d+)/.exec(React.version);
5+
6+
if (!match) {
7+
return false;
8+
}
9+
10+
const major = Number(match[1]);
11+
const minor = Number(match[2]);
12+
13+
if (major !== 19) {
14+
return major > 19;
15+
}
16+
17+
return minor >= targetMinor;
18+
}
19+
20+
export const testGateReact19_2 = isReactMinorOrNewer(2) ? test : test.skip;
21+
export const testGateReact19_3 = isReactMinorOrNewer(3) ? test : test.skip;

0 commit comments

Comments
 (0)