Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
92b18a95
Unverified
Commit
92b18a95
authored
Mar 04, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Mar 04, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] Use new Redbox matchers in app/ hook-functuon-names (#76785)
parent
235da189
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
56 deletions
+32
-56
hook-function-names.test.ts
...t/app-dir/hook-function-names/hook-function-names.test.ts
+32
-56
No files found.
test/development/app-dir/hook-function-names/hook-function-names.test.ts
View file @
92b18a95
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>"
`
)
}
})
})
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment