Skip to content

Commit

Permalink
chore(tests): eliminate rtl patch (#2878)
Browse files Browse the repository at this point in the history
* chore(tests): eliminate rtl patch

* fix workflow files

* consistent workflow files

* remove unused Promise.resolve

* rerender in tests
  • Loading branch information
dai-shi authored Dec 20, 2024
1 parent d0d8d0a commit 7883c4e
Show file tree
Hide file tree
Showing 20 changed files with 649 additions and 516 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test-multiple-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
- name: Use React 17 for production test
if: ${{ matrix.env == 'production' }}
run: |
pnpm json -I -f package.json -e "this.pnpm.patchedDependencies={};"
pnpm add -D [email protected] [email protected] @testing-library/[email protected]
- name: Patch for DEV-ONLY
if: ${{ matrix.env == 'development' }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test-multiple-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
- name: Install legacy testing-library
if: ${{ startsWith(matrix.react, '16.') || startsWith(matrix.react, '17.') }}
run: |
pnpm json -I -f package.json -e "this.pnpm.patchedDependencies={};"
pnpm add -D @testing-library/[email protected]
- name: Patch for React 16
if: ${{ startsWith(matrix.react, '16.') }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test-old-typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ jobs:
- name: Patch testing setup for older TS
if: ${{ matrix.typescript == '4.0.5' || startsWith(matrix.typescript, '3.') }}
run: |
pnpm json -I -f package.json -e "this.pnpm.patchedDependencies={};"
pnpm add -D @testing-library/[email protected] @testing-library/[email protected] @types/[email protected]
rm node_modules/vitest/dist/*.d.ts
echo "declare module 'vitest'" >> ./src/types.d.ts
Expand Down
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@
"jsdom": "^25.0.1",
"json": "^11.0.0",
"prettier": "^3.4.2",
"react": "19.0.0",
"react-dom": "19.0.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"rollup": "^4.28.1",
"rollup-plugin-banner2": "^1.3.1",
"rollup-plugin-esbuild": "^6.1.1",
Expand All @@ -182,10 +182,5 @@
"react": {
"optional": true
}
},
"pnpm": {
"patchedDependencies": {
"@testing-library/[email protected]": "patches/@[email protected]"
}
}
}
22 changes: 0 additions & 22 deletions patches/@[email protected]

This file was deleted.

20 changes: 7 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 43 additions & 31 deletions tests/react/abortable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ describe('abortable atom test', () => {
)
}

render(
<StrictMode>
<Suspense fallback="loading">
<Component />
<Controls />
</Suspense>
</StrictMode>,
)
// eslint-disable-next-line testing-library/no-unnecessary-act
await act(async () => {
render(
<StrictMode>
<Suspense fallback="loading">
<Component />
<Controls />
</Suspense>
</StrictMode>,
)
})

await screen.findByText('loading')

Expand Down Expand Up @@ -95,14 +98,17 @@ describe('abortable atom test', () => {
)
}

render(
<StrictMode>
<Suspense fallback="loading">
<Component />
<Controls />
</Suspense>
</StrictMode>,
)
// eslint-disable-next-line testing-library/no-unnecessary-act
await act(async () => {
render(
<StrictMode>
<Suspense fallback="loading">
<Component />
<Controls />
</Suspense>
</StrictMode>,
)
})

await screen.findByText('loading')
resolve.splice(0).forEach((fn) => fn())
Expand Down Expand Up @@ -154,13 +160,16 @@ describe('abortable atom test', () => {
)
}

render(
<StrictMode>
<Suspense fallback="loading">
<Parent />
</Suspense>
</StrictMode>,
)
// eslint-disable-next-line testing-library/no-unnecessary-act
await act(async () => {
render(
<StrictMode>
<Suspense fallback="loading">
<Parent />
</Suspense>
</StrictMode>,
)
})

await screen.findByText('loading')

Expand Down Expand Up @@ -203,14 +212,17 @@ describe('abortable atom test', () => {
)
}

render(
<StrictMode>
<Suspense fallback="loading">
<Component />
<Controls />
</Suspense>
</StrictMode>,
)
// eslint-disable-next-line testing-library/no-unnecessary-act
await act(async () => {
render(
<StrictMode>
<Suspense fallback="loading">
<Component />
<Controls />
</Suspense>
</StrictMode>,
)
})

await screen.findByText('loading')

Expand Down
Loading

0 comments on commit 7883c4e

Please sign in to comment.