Skip to content

Commit

Permalink
ci: test React 15
Browse files Browse the repository at this point in the history
  • Loading branch information
thebuilder committed Jun 8, 2024
1 parent 766d27b commit 4ee3469
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
fail-fast: false
matrix:
react:
- 15
- 16
- 17
- 18
Expand All @@ -49,11 +50,17 @@ jobs:
- name: Install legacy testing-library
if: ${{ startsWith(matrix.react, '16') || startsWith(matrix.react, '17') }}
run: pnpm add -D @testing-library/react@12.1.4
- name: Install legacy types
- name: Install legacy React types
if: ${{ startsWith(matrix.react, '16') || startsWith(matrix.react, '17') || startsWith(matrix.react, '18') }}
run: pnpm add -D @types/react@${{ matrix.react }} @types/react-dom@${{ matrix.react }}
- name: Test ${{ matrix.react }} ${{ matrix.devtools-skip }}
run: |
pnpm add -D react@${{ matrix.react }} react-dom@${{ matrix.react }}
pnpm test
pnpm tsc
- name: Install ${{ matrix.react }}
run: pnpm add -D react@${{ matrix.react }} react-dom@${{ matrix.react }}
- name: Validate types
run: pnpm tsc
- name: Test React 15
# Hooks are not supported in React 15, so skip testing it
if: ${{ startsWith(matrix.react, '15') }}
run: pnpm vitest InView observe setup
- name: Test React
if: ${{ !startsWith(matrix.react, '5') }}
run: pnpm test
2 changes: 1 addition & 1 deletion src/__tests__/InView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test("Should handle initialInView", () => {
const cb = vi.fn();
render(
<InView initialInView onChange={cb}>
{({ inView }) => `InView: ${inView}`}
{({ inView }) => <span>InView: {inView.toString()}</span>}
</InView>,
);
screen.getByText("InView: true");
Expand Down
1 change: 1 addition & 0 deletions src/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ declare global {
}

const act =
// @ts-expect-error - Older versions of React don't have the `act` method, so TypeScript will complain about it

Check failure on line 9 in src/test-utils.ts

View workflow job for this annotation

GitHub Actions / test

Unused '@ts-expect-error' directive.

Check failure on line 9 in src/test-utils.ts

View workflow job for this annotation

GitHub Actions / test

Unused '@ts-expect-error' directive.
typeof React.act === "function" ? React.act : DeprecatedReactTestUtils.act;

type Item = {
Expand Down

0 comments on commit 4ee3469

Please sign in to comment.