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
c9d93c45
Unverified
Commit
c9d93c45
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 pages/ gssp-ssr-change-reloading (#76788)
parent
29c27e83
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
35 deletions
+33
-35
index.test.ts
...opment/basic/gssp-ssr-change-reloading/test/index.test.ts
+33
-12
prerender.test.ts
test/e2e/prerender.test.ts
+0
-22
index.js
test/e2e/prerender/pages/index.js
+0
-1
No files found.
test/development/basic/gssp-ssr-change-reloading/test/index.test.ts
View file @
c9d93c45
...
...
@@ -3,12 +3,7 @@
import
{
join
}
from
'path'
import
webdriver
from
'next-webdriver'
import
{
createNext
,
FileRef
}
from
'e2e-utils'
import
{
assertHasRedbox
,
assertNoRedbox
,
check
,
getRedboxHeader
,
}
from
'next-test-utils'
import
{
assertNoRedbox
,
check
}
from
'next-test-utils'
import
{
NextInstance
}
from
'e2e-utils'
const
installCheckVisible
=
(
browser
)
=>
{
...
...
@@ -276,10 +271,22 @@ describe('GS(S)P Server-Side Change Reloading', () => {
try
{
await
next
.
patchFile
(
page
,
originalContent
.
replace
(
'props:'
,
'propss:'
))
await
assertHasRedbox
(
browser
)
expect
(
await
getRedboxHeader
(
browser
)).
toContain
(
'Additional keys were returned from'
)
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "Error: Additional keys were returned from \`getStaticProps\`. Properties intended for your component must be nested under the \`props\` key, e.g.:
return { props: { title: 'My Title', content: '...' } }
Keys that need to be moved: propss.
Read more: https://nextjs.org/docs/messages/invalid-getstaticprops-value",
"environmentLabel": null,
"label": "Runtime Error",
"source": null,
"stack": [],
}
`
)
await
next
.
patchFile
(
page
,
originalContent
)
await
assertNoRedbox
(
browser
)
...
...
@@ -306,8 +313,22 @@ describe('GS(S)P Server-Side Change Reloading', () => {
'throw new Error("custom oops"); const count'
)
)
await
assertHasRedbox
(
browser
)
expect
(
await
getRedboxHeader
(
browser
)).
toContain
(
'custom oops'
)
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "Error: custom oops",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/index.js (18:9) @ getStaticProps
> 18 | throw new Error("custom oops"); const count = 1
| ^",
"stack": [
"getStaticProps pages/index.js (18:9)",
],
}
`
)
expect
(
next
.
cliOutput
).
toMatch
(
/custom oops/
)
await
next
.
patchFile
(
page
,
originalContent
)
await
assertNoRedbox
(
browser
)
...
...
test/e2e/prerender.test.ts
View file @
c9d93c45
...
...
@@ -1152,28 +1152,6 @@ describe('Prerender', () => {
expect
(
JSON
.
parse
(
$2
(
'#__NEXT_DATA__'
).
text
()).
isFallback
).
toBe
(
false
)
})
it
(
'should log error in console and browser in development mode'
,
async
()
=>
{
const
browser
=
await
webdriver
(
next
.
url
,
'/'
)
expect
(
await
browser
.
elementByCss
(
'p'
).
text
()).
toMatch
(
/hello.*
?
world/
)
await
next
.
patchFile
(
'pages/index.js'
,
(
content
)
=>
content
.
replace
(
'// throw new'
,
'throw new'
),
async
()
=>
{
// we need to reload the page to trigger getStaticProps
await
browser
.
refresh
()
return
retry
(
async
()
=>
{
await
assertHasRedbox
(
browser
)
const
errOverlayContent
=
await
getRedboxHeader
(
browser
)
const
errorMsg
=
/oops from getStaticProps/
expect
(
next
.
cliOutput
).
toMatch
(
errorMsg
)
expect
(
errOverlayContent
).
toMatch
(
errorMsg
)
})
}
)
})
it
(
'should always call getStaticProps without caching in dev'
,
async
()
=>
{
const
initialRes
=
await
fetchViaHTTP
(
next
.
url
,
'/something'
)
expect
(
isCachingHeader
(
initialRes
.
headers
.
get
(
'cache-control'
))).
toBe
(
...
...
test/e2e/prerender/pages/index.js
View file @
c9d93c45
import
Link
from
'next/link'
export
async
function
getStaticProps
()
{
// throw new Error('oops from getStaticProps')
return
{
props
:
{
world
:
'world'
,
time
:
new
Date
().
getTime
()
},
// bad-prop
...
...
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