Unverified Commit 92b18a95 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[test] Use new Redbox matchers in app/ hook-functuon-names (#76785)

parent 235da189
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { assertHasRedbox, getRedboxSource, openRedbox } from 'next-test-utils'
describe('hook-function-names', () => { describe('hook-function-names', () => {
const { next, isTurbopack } = nextTestSetup({ const { next } = nextTestSetup({
files: __dirname, files: __dirname,
}) })
...@@ -11,64 +10,41 @@ describe('hook-function-names', () => { ...@@ -11,64 +10,41 @@ describe('hook-function-names', () => {
await browser.elementByCss('button').click() await browser.elementByCss('button').click()
await openRedbox(browser) await expect(browser).toDisplayCollapsedRedbox(`
{
if (isTurbopack) { "count": 1,
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` "description": "Error: Kaputt!",
"app/button/page.tsx (7:11) @ Button.useCallback[handleClick] "environmentLabel": null,
"label": "Unhandled Runtime Error",
5 | const Button = ({ message }: { message: string }) => { "source": "app/button/page.tsx (7:11) @ Button.useCallback[handleClick]
6 | const handleClick = useCallback(() => { > 7 | throw new Error(message)
> 7 | throw new Error(message) | ^",
| ^ "stack": [
8 | }, [message]) "Button.useCallback[handleClick] app/button/page.tsx (7:11)",
9 | "button <anonymous> (0:0)",
10 | return (" "Button app/button/page.tsx (11:5)",
`) "Page app/button/page.tsx (18:10)",
} else { ],
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` }
"app/button/page.tsx (7:11) @ Button.useCallback[handleClick] `)
5 | const Button = ({ message }: { message: string }) => {
6 | const handleClick = useCallback(() => {
> 7 | throw new Error(message)
| ^
8 | }, [message])
9 |
10 | return ("
`)
}
}) })
it('should show readable hook names in stacks for default-exported components', async () => { it('should show readable hook names in stacks for default-exported components', async () => {
const browser = await next.browser('/') const browser = await next.browser('/')
await assertHasRedbox(browser) await expect(browser).toDisplayRedbox(`
{
if (isTurbopack) { "count": 1,
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` "description": "Error: error in useEffect",
"app/page.tsx (7:11) @ Page.useEffect "environmentLabel": null,
"label": "Unhandled Runtime Error",
5 | export default function Page() { "source": "app/page.tsx (7:11) @ Page.useEffect
6 | useEffect(() => { > 7 | throw new Error('error in useEffect')
> 7 | throw new Error('error in useEffect') | ^",
| ^ "stack": [
8 | }, []) "Page.useEffect app/page.tsx (7:11)",
9 | ],
10 | return <p>Hello world!</p>" }
`) `)
} else {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"app/page.tsx (7:11) @ Page.useEffect
5 | export default function Page() {
6 | useEffect(() => {
> 7 | throw new Error('error in useEffect')
| ^
8 | }, [])
9 |
10 | return <p>Hello world!</p>"
`)
}
}) })
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment