File size: 1,189 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
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"
    `)
  })
})