diff --git a/e2e/site/app/react-server-entry/page.tsx b/e2e/site/app/react-server-entry/page.tsx new file mode 100644 index 000000000..9888eb171 --- /dev/null +++ b/e2e/site/app/react-server-entry/page.tsx @@ -0,0 +1,15 @@ +import { unstable_serialize } from 'swr' +import { unstable_serialize as infinite_unstable_serialize } from 'swr/infinite' + +export default function Page() { + return ( + <> +
SWR Server Component entry test
+
unstable_serialize: {unstable_serialize('useSWR')}
+
+ infinite_unstable_serialize:{' '} + {infinite_unstable_serialize(() => 'useSWRInfinite')} +
+ + ) +} diff --git a/e2e/test/initial-render.test.ts b/e2e/test/initial-render.test.ts index fa0f430bd..0c34e3ed9 100644 --- a/e2e/test/initial-render.test.ts +++ b/e2e/test/initial-render.test.ts @@ -29,4 +29,13 @@ test.describe('rendering', () => { await page.getByRole('button', { name: 'retry' }).click() await expect(page.getByText('data: SWR suspense retry works')).toBeVisible() }) + test('should be able to use `unstable_serialize` in server component', async ({ + page + }) => { + await page.goto('./react-server-entry', { waitUntil: 'commit' }) + await expect(page.getByText('unstable_serialize: useSWR')).toBeVisible() + await expect( + page.getByText('infinite_unstable_serialize: $inf$useSWRInfinite') + ).toBeVisible() + }) })