Skip to content

Commit 3d8bb39

Browse files
committed
CI matrix
1 parent d2ef116 commit 3d8bb39

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ on:
1010

1111
jobs:
1212
ci:
13-
name: CI
13+
name: CI (React ${{ matrix.react }})
1414
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
react: ['16.x', '17.x', '18.x', '19.0', '19.x']
1519
steps:
1620
- name: Checkout repo
1721
uses: actions/checkout@v4
@@ -25,6 +29,15 @@ jobs:
2529
- name: Install dependencies
2630
run: yarn install
2731

32+
- name: Install React ${{ matrix.react }}
33+
run:
34+
yarn add --dev react@${{ matrix.react }} react-dom@${{ matrix.react }}
35+
env:
36+
YARN_ENABLE_IMMUTABLE_INSTALLS: false
37+
38+
- name: Build package
39+
run: yarn build
40+
2841
- name: Run tests, lint and verify package integrity
2942
run: yarn run validate
3043

‎jest.config.cjs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,11 @@ const {jest: jestConfig} = require('kcd-scripts/config')
33
module.exports = Object.assign(jestConfig, {
44
resolver: 'ts-jest-resolver',
55
prettierPath: null,
6+
// React 16/17 use the legacy renderer and never call the client APIs.
7+
...(/^(16|17)\./.test(require('react').version) && {
8+
moduleNameMapper: {
9+
...jestConfig.moduleNameMapper,
10+
'^react-dom/client$': require.resolve('react-dom'),
11+
},
12+
}),
613
})

‎src/__tests__/renderHookToSnapshotStream.test.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {
99
} from '@testing-library/react-render-stream'
1010
import * as React from 'react'
1111

12+
const testWithExternalStore =
13+
typeof React.useSyncExternalStore === 'function' ? test : test.skip
14+
1215
const testEvents = new EventEmitter<{
1316
rerenderWithValue: [unknown]
1417
}>()
@@ -32,7 +35,7 @@ function useRerenderEvents(initialValue: unknown) {
3235
)
3336
}
3437

35-
test('basic functionality', async () => {
38+
testWithExternalStore('basic functionality', async () => {
3639
const {takeSnapshot} = await renderHookToSnapshotStream(useRerenderEvents, {
3740
initialProps: 'initial',
3841
})
@@ -53,7 +56,9 @@ test('basic functionality', async () => {
5356
}
5457
})
5558

56-
test.each<[type: string, initialValue: unknown, ...nextValues: unknown[]]>([
59+
testWithExternalStore.each<
60+
[type: string, initialValue: unknown, ...nextValues: unknown[]]
61+
>([
5762
['string', 'initial', 'value', 'value2'],
5863
['number', 0, 1, 2],
5964
['functions', () => {}, () => {}, function named() {}],

0 commit comments

Comments
 (0)