Skip to content

Commit

Permalink
test: add e2e test for react-server entry (#2671)
Browse files Browse the repository at this point in the history
  • Loading branch information
promer94 committed Jun 18, 2023
1 parent c30509f commit feb5c28
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions e2e/site/app/react-server-entry/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { unstable_serialize } from 'swr'
import { unstable_serialize as infinite_unstable_serialize } from 'swr/infinite'

export default function Page() {
return (
<>
<div>SWR Server Component entry test</div>
<div>unstable_serialize: {unstable_serialize('useSWR')}</div>
<div>
infinite_unstable_serialize:{' '}
{infinite_unstable_serialize(() => 'useSWRInfinite')}
</div>
</>
)
}
9 changes: 9 additions & 0 deletions e2e/test/initial-render.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})

0 comments on commit feb5c28

Please sign in to comment.