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
c2f1062b
Unverified
Commit
c2f1062b
authored
Nov 03, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Nov 03, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] Deflake root-optional-revalidate (#85584)
parent
73613d9d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
1 deletion
+98
-1
[[...slug]].js
...integration/root-optional-revalidate/pages/[[...slug]].js
+4
-1
index.test.ts
test/integration/root-optional-revalidate/test/index.test.ts
+94
-0
No files found.
test/integration/root-optional-revalidate/pages/[[...slug]].js
View file @
c2f1062b
...
@@ -13,7 +13,10 @@ export async function getStaticPaths() {
...
@@ -13,7 +13,10 @@ export async function getStaticPaths() {
}
}
}
}
export
async
function
getStaticProps
({
params
})
{
export
async
function
getStaticProps
({
params
,
revalidateReason
})
{
console
.
log
(
`getStaticProps({ revalidateReason:
${
JSON
.
stringify
(
revalidateReason
)}
})`
)
return
{
return
{
props
:
{
props
:
{
params
,
params
,
...
...
test/integration/root-optional-revalidate/test/index.test.
j
s
→
test/integration/root-optional-revalidate/test/index.test.
t
s
View file @
c2f1062b
/* eslint-env jest */
import
type
{
ChildProcess
}
from
'child_process'
import
{
join
}
from
'path'
import
{
join
}
from
'path'
import
cheerio
from
'cheerio'
import
cheerio
from
'cheerio'
import
{
import
{
...
@@ -9,11 +8,12 @@ import {
...
@@ -9,11 +8,12 @@ import {
nextStart
,
nextStart
,
renderViaHTTP
,
renderViaHTTP
,
waitFor
,
waitFor
,
retry
,
}
from
'next-test-utils'
}
from
'next-test-utils'
const
appDir
=
join
(
__dirname
,
'../'
)
const
appDir
=
join
(
__dirname
,
'../'
)
let
app
let
app
:
ChildProcess
|
undefined
let
appPort
let
appPort
:
number
|
undefined
const
getProps
=
async
(
path
)
=>
{
const
getProps
=
async
(
path
)
=>
{
const
html
=
await
renderViaHTTP
(
appPort
,
path
)
const
html
=
await
renderViaHTTP
(
appPort
,
path
)
...
@@ -26,36 +26,54 @@ const runTests = () => {
...
@@ -26,36 +26,54 @@ const runTests = () => {
const
props
=
await
getProps
(
'/'
)
const
props
=
await
getProps
(
'/'
)
expect
(
props
.
params
).
toEqual
({})
expect
(
props
.
params
).
toEqual
({})
let
cliOutput
=
''
app
.
stdout
.
on
(
'data'
,
(
chunk
)
=>
(
cliOutput
+=
chunk
.
toString
()))
await
waitFor
(
1000
)
await
waitFor
(
1000
)
await
getProps
(
'/'
)
await
getProps
(
'/'
)
expect
(
cliOutput
).
toEqual
(
'getStaticProps({ revalidateReason: "stale" })
\
n'
)
const
newProps
=
await
getProps
(
'/'
)
// Rendering takes time before the new cache entry is filled
expect
(
newProps
.
params
).
toEqual
({})
await
retry
(
async
()
=>
{
expect
(
props
.
random
).
not
.
toBe
(
newProps
.
random
)
const
newProps
=
await
getProps
(
'/'
)
expect
(
newProps
.
params
).
toEqual
({})
expect
(
props
.
random
).
not
.
toBe
(
newProps
.
random
)
})
})
})
it
(
'should render /a correctly'
,
async
()
=>
{
it
(
'should render /a correctly'
,
async
()
=>
{
const
props
=
await
getProps
(
'/a'
)
const
props
=
await
getProps
(
'/a'
)
expect
(
props
.
params
).
toEqual
({
slug
:
[
'a'
]
})
expect
(
props
.
params
).
toEqual
({
slug
:
[
'a'
]
})
let
cliOutput
=
''
app
.
stdout
.
on
(
'data'
,
(
chunk
)
=>
(
cliOutput
+=
chunk
.
toString
()))
await
waitFor
(
1000
)
await
waitFor
(
1000
)
await
getProps
(
'/a'
)
await
getProps
(
'/a'
)
expect
(
cliOutput
).
toEqual
(
'getStaticProps({ revalidateReason: "stale" })
\
n'
)
const
newProps
=
await
getProps
(
'/a'
)
// Rendering takes time before the new cache entry is filled
expect
(
newProps
.
params
).
toEqual
({
slug
:
[
'a'
]
})
await
retry
(
async
()
=>
{
expect
(
props
.
random
).
not
.
toBe
(
newProps
.
random
)
const
newProps
=
await
getProps
(
'/a'
)
expect
(
newProps
.
params
).
toEqual
({
slug
:
[
'a'
]
})
expect
(
props
.
random
).
not
.
toBe
(
newProps
.
random
)
})
})
})
it
(
'should render /hello/world correctly'
,
async
()
=>
{
it
(
'should render /hello/world correctly'
,
async
()
=>
{
const
props
=
await
getProps
(
'/hello/world'
)
const
props
=
await
getProps
(
'/hello/world'
)
expect
(
props
.
params
).
toEqual
({
slug
:
[
'hello'
,
'world'
]
})
expect
(
props
.
params
).
toEqual
({
slug
:
[
'hello'
,
'world'
]
})
let
cliOutput
=
''
app
.
stdout
.
on
(
'data'
,
(
chunk
)
=>
(
cliOutput
+=
chunk
.
toString
()))
await
waitFor
(
1000
)
await
waitFor
(
1000
)
await
getProps
(
'/hello/world'
)
await
getProps
(
'/hello/world'
)
expect
(
cliOutput
).
toEqual
(
'getStaticProps({ revalidateReason: "stale" })
\
n'
)
const
newProps
=
await
getProps
(
'/hello/world'
)
// Rendering takes time before the new cache entry is filled
expect
(
newProps
.
params
).
toEqual
({
slug
:
[
'hello'
,
'world'
]
})
await
retry
(
async
()
=>
{
expect
(
props
.
random
).
not
.
toBe
(
newProps
.
random
)
const
newProps
=
await
getProps
(
'/hello/world'
)
expect
(
newProps
.
params
).
toEqual
({
slug
:
[
'hello'
,
'world'
]
})
expect
(
props
.
random
).
not
.
toBe
(
newProps
.
random
)
})
})
})
}
}
...
...
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