File size: 1,391 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
import { nextTestSetup } from 'e2e-utils'

describe('hook-function-names', () => {
  const { next } = nextTestSetup({
    files: __dirname,
  })

  it('should show readable hook names in stacks', async () => {
    const browser = await next.browser('/button')

    await browser.elementByCss('button').click()

    await expect(browser).toDisplayCollapsedRedbox(`
     {
       "description": "Kaputt!",
       "environmentLabel": null,
       "label": "Runtime Error",
       "source": "app/button/page.tsx (7:11) @ Button.useCallback[handleClick]
     >  7 |     throw new Error(message)
          |           ^",
       "stack": [
         "Button.useCallback[handleClick] app/button/page.tsx (7:11)",
         "button <anonymous>",
         "Button app/button/page.tsx (11:5)",
         "Page app/button/page.tsx (18:10)",
       ],
     }
    `)
  })

  it('should show readable hook names in stacks for default-exported components', async () => {
    const browser = await next.browser('/')

    await expect(browser).toDisplayRedbox(`
     {
       "description": "error in useEffect",
       "environmentLabel": null,
       "label": "Runtime Error",
       "source": "app/page.tsx (7:11) @ Page.useEffect
     >  7 |     throw new Error('error in useEffect')
          |           ^",
       "stack": [
         "Page.useEffect app/page.tsx (7:11)",
       ],
     }
    `)
  })
})