Skip to content

Commit 6e8debe

Browse files
AyoubElkairhorns
authored andcommitted
add tests
1 parent 11749d3 commit 6e8debe

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Page } from 'playwright-chromium'
2+
import { newTestPage, rootURL } from '../../helpers'
3+
4+
// For these tests, we don't use reactReady because the page is rendered server side so we don't need to wait on the client side
5+
describe('imperative rendering', () => {
6+
let page: Page
7+
8+
beforeEach(async () => {
9+
page = await newTestPage()
10+
})
11+
12+
test('the route should not fetch props and hydrate on the client side', async () => {
13+
page.on('request', (request) => {
14+
if (request.headers().accept === 'application/json') {
15+
throw new Error(
16+
`Expecting request to only be rendered server side, props request made: ${request.method()} ${request.url()}`
17+
)
18+
}
19+
})
20+
21+
await page.goto(`${rootURL}/imperative-true`)
22+
})
23+
24+
test('the route handler should redirect to a 404 page', async () => {
25+
await page.goto(`${rootURL}/imperative/false`)
26+
expect(await page.isVisible("text='Not Found'")).toBe(true)
27+
})
28+
29+
test('the route handler should render the component', async () => {
30+
await page.goto(`${rootURL}/imperative/true`)
31+
expect(await page.isVisible("text='Imperatively renderable page'")).toBe(true)
32+
})
33+
})

0 commit comments

Comments
 (0)