Skip to content

Commit

Permalink
add test for server component
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Dec 6, 2022
1 parent 0631309 commit b616404
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Expand Up @@ -6,7 +6,7 @@ export default function Page() {
const [clicked, setClicked] = useState(false)
if (clicked) {
const e = new Error('this is a test')
e.digest = 'CUSTOM_DIGEST'
e.digest = 'CUSTOM_DIGEST_CLIENT'
throw e
}
return (
Expand Down
@@ -0,0 +1,5 @@
export default function Page() {
const e = new Error('this is a test')
e.digest = 'CUSTOM_DIGEST_SERVER'
throw e
}
13 changes: 11 additions & 2 deletions test/e2e/app-dir/index.test.ts
Expand Up @@ -2100,9 +2100,16 @@ describe('app dir', () => {
})

it('should use default error boundary for prod and overlay for dev when no error component specified', async () => {
// server
const html = await renderViaHTTP(
next.url,
'/error/global-error-boundary/server'
)

// client
const browser = await webdriver(
next.url,
'/error/global-error-boundary'
'/error/global-error-boundary/client'
)
await browser.elementByCss('#error-trigger-button').click()

Expand All @@ -2117,7 +2124,9 @@ describe('app dir', () => {
)
expect(
await browser.waitForElementByCss('body').elementByCss('p').text()
).toBe('Digest: CUSTOM_DIGEST')
).toBe('Digest: CUSTOM_DIGEST_CLIENT')

expect(html).toContain('Digest: CUSTOM_DIGEST_SERVER')
}
})

Expand Down

0 comments on commit b616404

Please sign in to comment.