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
0e9109e3
Unverified
Commit
0e9109e3
authored
Jul 13, 2024
by
Hendrik Liebau
Committed by
GitHub
Jul 13, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix flakiness of `error-hydration` test with turbopack (#67733)
parent
9b6f713b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
73 deletions
+49
-73
error-hydration.test.ts
test/production/error-hydration/error-hydration.test.ts
+46
-69
turbopack-build-tests-manifest.json
test/turbopack-build-tests-manifest.json
+3
-4
No files found.
test/production/error-hydration/error-hydration.test.ts
View file @
0e9109e3
import
{
NextInstance
,
nextTestSetup
}
from
'e2e-utils'
async
function
setupErrorHydrationTests
(
next
:
NextInstance
,
targetPath
:
string
)
{
const
consoleMessages
:
string
[]
=
[]
const
browser
=
await
next
.
browser
(
targetPath
,
{
beforePageLoad
(
page
)
{
page
.
on
(
'console'
,
(
event
)
=>
{
consoleMessages
.
push
(
event
.
text
())
})
},
})
return
[
browser
,
consoleMessages
]
as
const
}
import
{
nextTestSetup
}
from
'e2e-utils'
import
{
retry
}
from
'next-test-utils'
describe
(
'error-hydration'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
})
// Recommended for tests that need a full browser
it
(
'should log no error messages for server-side errors'
,
async
()
=>
{
const
[,
consoleMessages
]
=
await
setupErrorHydrationTests
(
next
,
'/with-error'
it
(
'should not log server-side errors'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/with-error'
)
const
messages
=
await
browser
.
log
()
expect
(
messages
).
not
.
toEqual
(
expect
.
arrayContaining
([
{
message
:
expect
.
stringContaining
(
'Error: custom error'
),
source
:
'error'
,
},
])
)
expect
(
consoleMessages
.
find
((
message
)
=>
message
.
startsWith
(
'A client-side exception has occurred'
)
)
).
toBeUndefined
()
expect
(
consoleMessages
.
find
(
(
message
)
=>
message
===
'{name: Internal Server Error., message: 500 - Internal Server Error., statusCode: 500}'
)
).
toBeUndefined
()
})
it
(
'should not invoke the error page getInitialProps client-side for server-side errors'
,
async
()
=>
{
const
[
b
]
=
await
setupErrorHydrationTests
(
next
,
'/with-error'
)
const
browser
=
await
next
.
browser
(
'/with-error'
)
expect
(
await
b
.
eval
(
await
b
rowser
.
eval
(
()
=>
(
window
as
any
).
__ERROR_PAGE_GET_INITIAL_PROPS_INVOKED_CLIENT_SIDE__
)
).
toBe
(
undefined
)
})
it
(
'should log an message for client-side errors, including the full, custom error'
,
async
()
=>
{
const
[
browser
,
consoleMessages
]
=
await
setupErrorHydrationTests
(
next
,
'/no-error'
)
const
link
=
await
browser
.
elementByCss
(
'a'
)
await
link
.
click
()
expect
(
consoleMessages
.
some
((
m
)
=>
m
.
includes
(
'Error: custom error'
))).
toBe
(
true
)
expect
(
consoleMessages
.
some
((
m
)
=>
m
.
includes
(
'A client-side exception has occurred, see here for more info'
)
it
(
'should log a message for client-side errors, including the full, custom error'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/no-error'
)
await
browser
.
elementByCss
(
'a'
).
click
()
const
messages
=
await
browser
.
log
()
retry
(()
=>
{
expect
(
messages
).
toEqual
(
expect
.
arrayContaining
([
{
message
:
expect
.
stringContaining
(
'Error: custom error'
),
source
:
'error'
,
},
{
message
:
expect
.
stringContaining
(
'A client-side exception has occurred, see here for more info'
),
source
:
'error'
,
},
])
)
).
toBe
(
true
)
}
)
})
it
(
"invokes _error's getInitialProps for client-side errors"
,
async
()
=>
{
const
[
browser
]
=
await
setupErrorHydrationTests
(
next
,
'/no-error'
)
const
link
=
await
browser
.
elementByCss
(
'a'
)
await
link
.
click
()
expect
(
await
browser
.
eval
(
()
=>
(
window
as
any
).
__ERROR_PAGE_GET_INITIAL_PROPS_INVOKED_CLIENT_SIDE__
)
).
toBe
(
true
)
const
browser
=
await
next
.
browser
(
'/no-error'
)
await
browser
.
elementByCss
(
'a'
).
click
()
retry
(
async
()
=>
{
expect
(
await
browser
.
eval
(
()
=>
(
window
as
any
).
__ERROR_PAGE_GET_INITIAL_PROPS_INVOKED_CLIENT_SIDE__
)
)
.
toBe
(
true
)
}
)
})
})
test/turbopack-build-tests-manifest.json
View file @
0e9109e3
...
...
@@ -15671,12 +15671,11 @@
"test/production/error-hydration/error-hydration.test.ts"
:
{
"passed"
:
[
"error-hydration invokes _error's getInitialProps for client-side errors"
,
"error-hydration should log no error messages for server-side errors"
,
"error-hydration should log a message for client-side errors, including the full, custom error"
,
"error-hydration should not log server-side errors"
,
"error-hydration should not invoke the error page getInitialProps client-side for server-side errors"
],
"failed"
:
[
"error-hydration should log an message for client-side errors, including the full, custom error"
],
"failed"
:
[],
"pending"
:
[],
"flakey"
:
[],
"runtimeError"
:
false
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