File size: 1,913 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
describe('error-hydration', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should not log server-side errors', async () => {
const browser = await next.browser('/with-error')
const messages = await browser.log()
expect(messages).not.toEqual(
expect.arrayContaining([
{
message: expect.stringContaining('Error: custom error'),
source: 'error',
},
])
)
})
it('should not invoke the error page getInitialProps client-side for server-side errors', async () => {
const browser = await next.browser('/with-error')
expect(
await browser.eval(
() =>
(window as any).__ERROR_PAGE_GET_INITIAL_PROPS_INVOKED_CLIENT_SIDE__
)
).toBe(undefined)
})
it('should log a message for client-side errors, including the full, custom error', async () => {
const browser = await next.browser('/no-error')
await browser.elementByCss('a').click()
const messages = await browser.log()
retry(() => {
expect(messages).toEqual(
expect.arrayContaining([
{
message: expect.stringContaining('Error: custom error'),
source: 'error',
},
{
message: expect.stringContaining(
'A client-side exception has occurred, see here for more info'
),
source: 'error',
},
])
)
})
})
it("invokes _error's getInitialProps for client-side errors", async () => {
const browser = await next.browser('/no-error')
await browser.elementByCss('a').click()
retry(async () => {
expect(
await browser.eval(
() =>
(window as any).__ERROR_PAGE_GET_INITIAL_PROPS_INVOKED_CLIENT_SIDE__
)
).toBe(true)
})
})
})
|