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
d5cefb26
Unverified
Commit
d5cefb26
authored
Feb 21, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Feb 21, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] Use new Redbox matchers in pages/ hydration-error test (#76350)
parent
6b2aec16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
339 additions
and
317 deletions
+339
-317
hydration-error.test.ts
test/development/acceptance/hydration-error.test.ts
+311
-307
add-redbox-matchers.ts
test/lib/add-redbox-matchers.ts
+28
-10
No files found.
test/development/acceptance/hydration-error.test.ts
View file @
d5cefb26
This diff is collapsed.
Click to expand it.
test/lib/add-redbox-matchers.ts
View file @
d5cefb26
...
@@ -3,6 +3,7 @@ import { toMatchInlineSnapshot } from 'jest-snapshot'
...
@@ -3,6 +3,7 @@ import { toMatchInlineSnapshot } from 'jest-snapshot'
import
{
import
{
assertHasRedbox
,
assertHasRedbox
,
getRedboxCallStack
,
getRedboxCallStack
,
getRedboxComponentStack
,
getRedboxDescription
,
getRedboxDescription
,
getRedboxEnvironmentLabel
,
getRedboxEnvironmentLabel
,
getRedboxSource
,
getRedboxSource
,
...
@@ -51,6 +52,7 @@ interface RedboxSnapshot {
...
@@ -51,6 +52,7 @@ interface RedboxSnapshot {
environmentLabel
:
string
environmentLabel
:
string
label
:
string
label
:
string
description
:
string
description
:
string
componentStack
?:
string
source
:
string
source
:
string
stack
:
string
[]
stack
:
string
[]
count
:
number
count
:
number
...
@@ -59,15 +61,23 @@ interface RedboxSnapshot {
...
@@ -59,15 +61,23 @@ interface RedboxSnapshot {
async
function
createRedboxSnapshot
(
async
function
createRedboxSnapshot
(
browser
:
BrowserInterface
browser
:
BrowserInterface
):
Promise
<
RedboxSnapshot
>
{
):
Promise
<
RedboxSnapshot
>
{
const
[
label
,
environmentLabel
,
description
,
source
,
stack
,
count
]
=
const
[
await
Promise
.
all
([
label
,
getRedboxLabel
(
browser
),
environmentLabel
,
getRedboxEnvironmentLabel
(
browser
),
description
,
getRedboxDescription
(
browser
),
source
,
getRedboxSource
(
browser
),
stack
,
getRedboxCallStack
(
browser
),
componentStack
,
getRedboxTotalErrorCount
(
browser
),
count
,
])
]
=
await
Promise
.
all
([
getRedboxLabel
(
browser
),
getRedboxEnvironmentLabel
(
browser
),
getRedboxDescription
(
browser
),
getRedboxSource
(
browser
),
getRedboxCallStack
(
browser
),
getRedboxComponentStack
(
browser
),
getRedboxTotalErrorCount
(
browser
),
])
// We don't need to test the codeframe logic everywhere.
// We don't need to test the codeframe logic everywhere.
// Here we focus on the cursor position of the top most frame
// Here we focus on the cursor position of the top most frame
...
@@ -111,7 +121,7 @@ async function createRedboxSnapshot(
...
@@ -111,7 +121,7 @@ async function createRedboxSnapshot(
}
}
}
}
return
{
const
snapshot
:
RedboxSnapshot
=
{
environmentLabel
,
environmentLabel
,
label
,
label
,
description
,
description
,
...
@@ -120,6 +130,14 @@ async function createRedboxSnapshot(
...
@@ -120,6 +130,14 @@ async function createRedboxSnapshot(
// TODO(newDevOverlay): Always return `count`. Normalizing currently to avoid assertion forks.
// TODO(newDevOverlay): Always return `count`. Normalizing currently to avoid assertion forks.
count
:
label
===
'Build Error'
&&
count
===
-
1
?
1
:
count
,
count
:
label
===
'Build Error'
&&
count
===
-
1
?
1
:
count
,
}
}
// Hydration diffs are only relevant to some specific errors
// so we hide them from the snapshots unless they are present.
if
(
componentStack
!==
null
)
{
snapshot
.
componentStack
=
componentStack
}
return
snapshot
}
}
expect
.
extend
({
expect
.
extend
({
...
...
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