swr
swr copied to clipboard
SWR + React 19: Tests with Suspense fail to transition from loading state
Bug report
Description / Observed Behavior
When using SWR with Suspense mode (suspense: true) in React 19, tests fail to transition from loading to success/error states. Components remain stuck in the loading state and tests timeout.
Expected Behavior
Components should:
- Show loading state initially
- Transition to success/error state after data loads
Repro Steps / Code Example
Using SWR:
const { data } = useSWR(key, fetcher, { suspense: true });
Test case:
test('transition from loading to success', async () => {
render(
<Suspense fallback={<Loading />}>
<Component />
</Suspense>
);
expect(screen.getByTestId('loading')).toBeInTheDocument();
await waitForElementToBeRemoved(() => screen.getByTestId('loading'));
});
Additional Context
Environment:
SWR 2.3.0 React 19.0.0 @testing-library/react 16.1.0
please assign to me this issues
https://github.com/testing-library/react-testing-library/issues/1375