-
Notifications
You must be signed in to change notification settings - Fork 28k
/
Copy pathformat-server-error.test.ts
30 lines (24 loc) · 1.16 KB
/
format-server-error.test.ts
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
import { formatServerError } from './format-server-error'
describe('formatServerError', () => {
it('should not append message several times', () => {
const err = new Error(
'Class extends value undefined is not a constructor or null'
)
// Before
expect(err.message).toMatchInlineSnapshot(
`"Class extends value undefined is not a constructor or null"`
)
// After
formatServerError(err)
expect(err.message).toMatchInlineSnapshot(`
"Class extends value undefined is not a constructor or null
This might be caused by a React Class Component being rendered in a Server Component, React Class Components only works in Client Components. Read more: https://nextjs.org/docs/messages/class-component-in-server-component"
`)
// After second
formatServerError(err)
expect(err.message).toMatchInlineSnapshot(`
"Class extends value undefined is not a constructor or null
This might be caused by a React Class Component being rendered in a Server Component, React Class Components only works in Client Components. Read more: https://nextjs.org/docs/messages/class-component-in-server-component"
`)
})
})