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
2cf4ffee
Unverified
Commit
2cf4ffee
authored
Oct 16, 2026
by
Niklas Mischkulnig
Committed by
GitHub
Oct 28, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more tests
parent
71a6fb90
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
1 deletion
+53
-1
index.test.ts
test/e2e/middleware-matcher/index.test.ts
+53
-1
No files found.
test/e2e/middleware-matcher/index.test.ts
View file @
2cf4ffee
...
@@ -675,7 +675,13 @@ describe.each([
...
@@ -675,7 +675,13 @@ describe.each([
`
,
`
,
'middleware.js'
:
`
'middleware.js'
:
`
import { NextResponse } from 'next/server'
import { NextResponse } from 'next/server'
export const config = { matcher: '/' };
export const config = {
matcher: [
'/',
'/with-locale',
{ source: '/es/without-locale', locale: false },
],
};
export default (req) => {
export default (req) => {
const res = NextResponse.next();
const res = NextResponse.next();
res.headers.set('X-From-Middleware', 'true');
res.headers.set('X-From-Middleware', 'true');
...
@@ -697,6 +703,52 @@ describe.each([
...
@@ -697,6 +703,52 @@ describe.each([
dependencies
:
{},
dependencies
:
{},
})
})
it
.
each
([
{
path
:
'/with-locale'
,
locale
:
'en'
,
matched
:
true
},
{
path
:
'/es/with-locale'
,
locale
:
'es'
,
matched
:
true
},
{
path
:
'/without-locale'
,
locale
:
'en'
,
matched
:
false
},
{
path
:
'/en/without-locale'
,
locale
:
'en'
,
matched
:
false
},
{
path
:
'/es/without-locale'
,
locale
:
'es'
,
matched
:
true
},
])(
'respects matcher locale settings for $path with basePath'
,
async
({
path
,
locale
,
matched
})
=>
{
const
response
=
await
fetchViaHTTP
(
next
.
url
,
`/root
${
path
}
`
)
expect
(
response
.
status
).
toBe
(
200
)
expect
(
await
response
.
text
()).
toContain
(
`(
${
locale
}
) Hello from /
${
path
.
split
(
'/'
).
pop
()}
`
)
expect
(
response
.
headers
.
get
(
'X-From-Middleware'
)).
toBe
(
matched
?
'true'
:
null
)
}
)
it
.
each
([
{
path
:
'en/with-locale'
,
locale
:
'en'
,
matched
:
true
},
{
path
:
'es/with-locale'
,
locale
:
'es'
,
matched
:
true
},
{
path
:
'en/without-locale'
,
locale
:
'en'
,
matched
:
false
},
{
path
:
'es/without-locale'
,
locale
:
'es'
,
matched
:
true
},
])(
'respects matcher locale settings for the $path data route with basePath'
,
async
({
path
,
locale
,
matched
})
=>
{
const
response
=
await
fetchViaHTTP
(
next
.
url
,
`/root/_next/data/
${
next
.
buildId
}
/
${
path
}
.json`
,
undefined
,
{
headers
:
{
'x-nextjs-data'
:
'1'
}
}
)
expect
(
response
.
status
).
toBe
(
200
)
expect
(
await
response
.
json
()).
toMatchObject
({
pageProps
:
{
message
:
`(
${
locale
}
) Hello from /
${
path
.
split
(
'/'
).
pop
()}
`
,
},
})
expect
(
response
.
headers
.
get
(
'X-From-Middleware'
)).
toBe
(
matched
?
'true'
:
null
)
}
)
it
(
`adds the header for a matched path`
,
async
()
=>
{
it
(
`adds the header for a matched path`
,
async
()
=>
{
const
res1
=
await
fetchViaHTTP
(
next
.
url
,
`/root`
)
const
res1
=
await
fetchViaHTTP
(
next
.
url
,
`/root`
)
expect
(
await
res1
.
text
()).
toContain
(
`(en) Hello from /`
)
expect
(
await
res1
.
text
()).
toContain
(
`(en) Hello from /`
)
...
...
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