forked from nickserv/rsc-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df4409b
commit 9e4aa67
Showing
2 changed files
with
14 additions
and
59 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
import { screen } from '@testing-library/react' | ||
import { screen, render, waitFor } from '@testing-library/react' | ||
import Layout from './layout' | ||
import Page from './page' | ||
import serverRender from './serverRender' | ||
import { Suspense } from 'react' | ||
|
||
beforeEach(() => serverRender(<Page />, { wrapper: Layout })) | ||
beforeEach(() => | ||
render( | ||
<Suspense fallback={<p>Loading...</p>}> | ||
<Layout> | ||
<Page /> | ||
</Layout> | ||
</Suspense> | ||
) | ||
) | ||
|
||
test.each(['client', 'server', 'layout'])(`%s component`, (keyword) => { | ||
expect(screen.getByText(keyword)).toBeInTheDocument() | ||
test.each(['client', 'server', 'layout'])(`%s component`, async (keyword) => { | ||
expect(screen.getByText('Loading...')).toBeInTheDocument() | ||
await waitFor(() => expect(screen.getByText(keyword)).toBeInTheDocument()) | ||
}) |