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
f814b8b5
Unverified
Commit
f814b8b5
authored
Jan 12, 2026
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Jan 12, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] Deflake `test/integration/invalid-custom-routes/test/index.test.ts` (#88416)
parent
f8553f86
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
178 additions
and
148 deletions
+178
-148
index.test.ts
test/integration/invalid-custom-routes/test/index.test.ts
+178
-148
No files found.
test/integration/invalid-custom-routes/test/index.test.ts
View file @
f814b8b5
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
import
fs
from
'fs-extra'
import
fs
from
'fs-extra'
import
{
join
}
from
'path'
import
{
join
}
from
'path'
import
{
launchApp
,
findPort
,
nextBuild
,
retry
}
from
'next-test-utils'
import
{
launchApp
,
findPort
,
nextBuild
,
retry
,
killApp
}
from
'next-test-utils'
let
appDir
=
join
(
__dirname
,
'..'
)
let
appDir
=
join
(
__dirname
,
'..'
)
const
nextConfigPath
=
join
(
appDir
,
'next.config.js'
)
const
nextConfigPath
=
join
(
appDir
,
'next.config.js'
)
...
@@ -21,6 +21,7 @@ const writeConfig = async (routes, type = 'redirects') => {
...
@@ -21,6 +21,7 @@ const writeConfig = async (routes, type = 'redirects') => {
}
}
let
getStderr
let
getStderr
let
start
const
runTests
=
()
=>
{
const
runTests
=
()
=>
{
it
(
'should error when empty headers array is present on header item'
,
async
()
=>
{
it
(
'should error when empty headers array is present on header item'
,
async
()
=>
{
...
@@ -33,9 +34,9 @@ const runTests = () => {
...
@@ -33,9 +34,9 @@ const runTests = () => {
],
],
'headers'
'headers'
)
)
await
retry
(
async
()
=>
{
await
start
()
const
stderr
=
await
getStderr
()
await
retry
(()
=>
{
const
stderr
=
getStderr
()
expect
(
stderr
).
toContain
(
expect
(
stderr
).
toContain
(
'`headers` field cannot be empty for route {"source":"/:path*"'
'`headers` field cannot be empty for route {"source":"/:path*"'
)
)
...
@@ -58,8 +59,9 @@ const runTests = () => {
...
@@ -58,8 +59,9 @@ const runTests = () => {
],
],
'redirects'
'redirects'
)
)
const
stderr
=
await
getStderr
()
await
start
()
await
retry
(()
=>
{
const
stderr
=
getStderr
()
expect
(
stderr
).
toContain
(
expect
(
stderr
).
toContain
(
'`source` exceeds max built length of 4096 for route {"source":"/aaaaaaaaaaaaaaaaaa'
'`source` exceeds max built length of 4096 for route {"source":"/aaaaaaaaaaaaaaaaaa'
)
)
...
@@ -67,6 +69,7 @@ const runTests = () => {
...
@@ -67,6 +69,7 @@ const runTests = () => {
'`destination` exceeds max built length of 4096 for route {"source":"/","destination":"/aaaa'
'`destination` exceeds max built length of 4096 for route {"source":"/","destination":"/aaaa'
)
)
})
})
})
it
(
'should error during next build for invalid redirects'
,
async
()
=>
{
it
(
'should error during next build for invalid redirects'
,
async
()
=>
{
await
writeConfig
(
await
writeConfig
(
...
@@ -139,10 +142,9 @@ const runTests = () => {
...
@@ -139,10 +142,9 @@ const runTests = () => {
],
],
'redirects'
'redirects'
)
)
await
start
()
await
retry
(
async
()
=>
{
await
retry
(()
=>
{
const
stderr
=
await
getStderr
()
const
stderr
=
getStderr
()
expect
(
stderr
).
toContain
(
expect
(
stderr
).
toContain
(
`\`destination\` is missing for route {"source":"/hello","permanent":false}`
`\`destination\` is missing for route {"source":"/hello","permanent":false}`
)
)
...
@@ -273,8 +275,9 @@ const runTests = () => {
...
@@ -273,8 +275,9 @@ const runTests = () => {
],
],
'rewrites'
'rewrites'
)
)
const
stderr
=
await
getStderr
()
await
start
()
await
retry
(()
=>
{
const
stderr
=
getStderr
()
expect
(
stderr
).
toContain
(
expect
(
stderr
).
toContain
(
`\`destination\` is missing for route {"source":"/hello"}`
`\`destination\` is missing for route {"source":"/hello"}`
)
)
...
@@ -344,6 +347,7 @@ const runTests = () => {
...
@@ -344,6 +347,7 @@ const runTests = () => {
expect
(
stderr
).
toContain
(
'Invalid rewrites found'
)
expect
(
stderr
).
toContain
(
'Invalid rewrites found'
)
})
})
})
it
(
'should error during next build for invalid headers'
,
async
()
=>
{
it
(
'should error during next build for invalid headers'
,
async
()
=>
{
await
writeConfig
(
await
writeConfig
(
...
@@ -447,8 +451,9 @@ const runTests = () => {
...
@@ -447,8 +451,9 @@ const runTests = () => {
],
],
'headers'
'headers'
)
)
const
stderr
=
await
getStderr
()
await
start
()
await
retry
(()
=>
{
const
stderr
=
getStderr
()
expect
(
stderr
).
toContain
(
expect
(
stderr
).
toContain
(
'`source` is missing, `key` in header item must be string for route {"headers":[{"x-first":"first"}]}'
'`source` is missing, `key` in header item must be string for route {"headers":[{"x-first":"first"}]}'
)
)
...
@@ -499,6 +504,7 @@ const runTests = () => {
...
@@ -499,6 +504,7 @@ const runTests = () => {
expect
(
stderr
).
not
.
toContain
(
'/valid-header'
)
expect
(
stderr
).
not
.
toContain
(
'/valid-header'
)
})
})
})
it
(
'should show formatted error for redirect source parse fail'
,
async
()
=>
{
it
(
'should show formatted error for redirect source parse fail'
,
async
()
=>
{
await
writeConfig
(
await
writeConfig
(
...
@@ -516,9 +522,9 @@ const runTests = () => {
...
@@ -516,9 +522,9 @@ const runTests = () => {
],
],
'redirects'
'redirects'
)
)
await
start
()
const
stderr
=
await
getStderr
()
await
retry
(()
=>
{
const
stderr
=
getStderr
()
expect
(
stderr
).
toContain
(
expect
(
stderr
).
toContain
(
`Error parsing \`/feedback/(?!general)\` https://nextjs.org/docs/messages/invalid-route-source`
`Error parsing \`/feedback/(?!general)\` https://nextjs.org/docs/messages/invalid-route-source`
)
)
...
@@ -528,9 +534,12 @@ const runTests = () => {
...
@@ -528,9 +534,12 @@ const runTests = () => {
expect
(
stderr
).
toContain
(
expect
(
stderr
).
toContain
(
`Error parsing \`/learning/?\` https://nextjs.org/docs/messages/invalid-route-source`
`Error parsing \`/learning/?\` https://nextjs.org/docs/messages/invalid-route-source`
)
)
expect
(
stderr
).
toContain
(
`Reason: Unexpected MODIFIER at 10, expected END`
)
expect
(
stderr
).
toContain
(
`Reason: Unexpected MODIFIER at 10, expected END`
)
expect
(
stderr
).
toContain
(
`/learning/?`
)
expect
(
stderr
).
toContain
(
`/learning/?`
)
})
})
})
it
(
'should show valid error when non-array is returned from rewrites'
,
async
()
=>
{
it
(
'should show valid error when non-array is returned from rewrites'
,
async
()
=>
{
await
writeConfig
(
await
writeConfig
(
...
@@ -541,25 +550,35 @@ const runTests = () => {
...
@@ -541,25 +550,35 @@ const runTests = () => {
'rewrites'
'rewrites'
)
)
const
stderr
=
await
getStderr
()
await
start
()
await
retry
(()
=>
{
const
stderr
=
getStderr
()
expect
(
stderr
).
toContain
(
`rewrites must return an array, received object`
)
expect
(
stderr
).
toContain
(
`rewrites must return an array, received object`
)
})
})
})
it
(
'should show valid error when non-array is returned from redirects'
,
async
()
=>
{
it
(
'should show valid error when non-array is returned from redirects'
,
async
()
=>
{
await
writeConfig
(
false
,
'redirects'
)
await
writeConfig
(
false
,
'redirects'
)
const
stderr
=
await
getStderr
()
await
start
()
await
retry
(()
=>
{
expect
(
stderr
).
toContain
(
`redirects must return an array, received boolean`
)
const
stderr
=
getStderr
()
expect
(
stderr
).
toContain
(
`redirects must return an array, received boolean`
)
})
})
})
it
(
'should show valid error when non-array is returned from headers'
,
async
()
=>
{
it
(
'should show valid error when non-array is returned from headers'
,
async
()
=>
{
await
writeConfig
(
undefined
,
'headers'
)
await
writeConfig
(
undefined
,
'headers'
)
const
stderr
=
await
getStderr
()
await
start
()
await
retry
(()
=>
{
expect
(
stderr
).
toContain
(
`headers must return an array, received undefined`
)
const
stderr
=
getStderr
()
expect
(
stderr
).
toContain
(
`headers must return an array, received undefined`
)
})
})
})
it
(
'should show valid error when segments not in source are used in destination'
,
async
()
=>
{
it
(
'should show valid error when segments not in source are used in destination'
,
async
()
=>
{
...
@@ -573,12 +592,14 @@ const runTests = () => {
...
@@ -573,12 +592,14 @@ const runTests = () => {
'rewrites'
'rewrites'
)
)
const
stderr
=
await
getStderr
()
await
start
()
await
retry
(()
=>
{
const
stderr
=
getStderr
()
expect
(
stderr
).
toContain
(
expect
(
stderr
).
toContain
(
`\`destination\` has segments not in \`source\` or \`has\` (id) for route {"source":"/feedback/:type","destination":"/feedback/:id"}`
`\`destination\` has segments not in \`source\` or \`has\` (id) for route {"source":"/feedback/:type","destination":"/feedback/:id"}`
)
)
})
})
})
}
}
describe
(
'Errors on invalid custom routes'
,
()
=>
{
describe
(
'Errors on invalid custom routes'
,
()
=>
{
...
@@ -587,18 +608,25 @@ describe('Errors on invalid custom routes', () => {
...
@@ -587,18 +608,25 @@ describe('Errors on invalid custom routes', () => {
'development mode'
,
'development mode'
,
()
=>
{
()
=>
{
let
stderr
=
''
let
stderr
=
''
let
app
beforeAll
(()
=>
{
beforeAll
(()
=>
{
getStderr
=
async
()
=>
{
getStderr
=
()
=>
stderr
start
=
async
()
=>
{
const
port
=
await
findPort
()
const
port
=
await
findPort
()
await
launchApp
(
appDir
,
port
,
{
stderr
=
''
app
=
await
launchApp
(
appDir
,
port
,
{
onStderr
:
(
msg
)
=>
{
onStderr
:
(
msg
)
=>
{
stderr
+=
msg
stderr
+=
msg
},
},
})
})
return
stderr
}
}
})
})
afterEach
(()
=>
{
afterEach
(
async
()
=>
{
if
(
app
)
{
await
killApp
(
app
)
app
=
null
}
stderr
=
''
stderr
=
''
})
})
...
@@ -609,9 +637,11 @@ describe('Errors on invalid custom routes', () => {
...
@@ -609,9 +637,11 @@ describe('Errors on invalid custom routes', () => {
'production mode'
,
'production mode'
,
()
=>
{
()
=>
{
beforeAll
(()
=>
{
beforeAll
(()
=>
{
getStderr
=
async
()
=>
{
let
stderr
=
''
const
{
stderr
}
=
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
})
getStderr
=
()
=>
stderr
return
stderr
start
=
async
()
=>
{
const
result
=
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
})
stderr
=
result
.
stderr
}
}
})
})
...
...
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