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
cac2dd80
Unverified
Commit
cac2dd80
authored
Oct 30, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Oct 30, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] Disallow custom `RegExp`-like implementations in `check` (#85537)
parent
6deb31e4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
63 deletions
+38
-63
basepath.test.ts
test/e2e/basepath/basepath.test.ts
+15
-22
error-pages.test.ts
test/e2e/basepath/error-pages.test.ts
+7
-13
index.test.ts
test/e2e/getserversideprops/test/index.test.ts
+3
-7
index.test.ts
test/e2e/link-with-api-rewrite/index.test.ts
+5
-5
prerender.test.ts
test/e2e/prerender.test.ts
+6
-14
next-test-utils.ts
test/lib/next-test-utils.ts
+2
-2
No files found.
test/e2e/basepath/basepath.test.ts
View file @
cac2dd80
...
...
@@ -126,33 +126,26 @@ describe('basePath', () => {
'/gssp'
)
await
check
(
async
()
=>
{
const
links
=
await
browser
.
elementsByCss
(
'link[rel=prefetch]'
)
for
(
const
link
of
links
)
{
const
href
=
await
link
.
getAttribute
(
'href'
)
if
(
href
.
includes
(
chunk
))
{
return
true
}
await
check
(
async
()
=>
{
const
links
=
await
browser
.
elementsByCss
(
'link[rel=prefetch]'
)
for
(
const
link
of
links
)
{
const
href
=
await
link
.
getAttribute
(
'href'
)
if
(
href
.
includes
(
chunk
))
{
return
true
}
}
const
scripts
=
await
browser
.
elementsByCss
(
'script'
)
const
scripts
=
await
browser
.
elementsByCss
(
'script'
)
for
(
const
script
of
scripts
)
{
const
src
=
await
script
.
getAttribute
(
'src'
)
if
(
src
.
includes
(
chunk
))
{
return
true
}
for
(
const
script
of
scripts
)
{
const
src
=
await
script
.
getAttribute
(
'src'
)
if
(
src
.
includes
(
chunk
))
{
return
true
}
return
false
},
{
test
(
result
)
{
return
result
===
true
},
}
)
return
false
},
true
)
})
it
(
'should prefetch pages correctly in viewport with <Link>'
,
async
()
=>
{
...
...
test/e2e/basepath/error-pages.test.ts
View file @
cac2dd80
import
webdriver
from
'next-webdriver'
import
{
nextTestSetup
}
from
'e2e-utils'
import
{
check
,
renderViaHTTP
}
from
'next-test-utils'
import
{
check
,
renderViaHTTP
,
retry
}
from
'next-test-utils'
describe
(
'basePath'
,
()
=>
{
const
basePath
=
'/docs'
...
...
@@ -121,10 +121,8 @@ describe('basePath', () => {
await
browser
.
eval
(
'window.beforeNav = "hi"'
)
await
browser
.
elementByCss
(
'#other-page-link'
).
click
()
await
check
(()
=>
browser
.
eval
(
'window.beforeNav'
),
{
test
(
content
)
{
return
content
!==
'hi'
},
await
retry
(
async
()
=>
{
expect
(
await
browser
.
eval
(
'window.beforeNav'
)).
not
.
toEqual
(
'hi'
)
})
await
check
(
...
...
@@ -138,10 +136,8 @@ describe('basePath', () => {
await
browser
.
eval
(
'window.beforeNav = "hi"'
)
await
browser
.
eval
(
`window.next.router.push("
${
basePath
}
/other-page")`
)
await
check
(()
=>
browser
.
eval
(
'window.beforeNav'
),
{
test
(
content
)
{
return
content
!==
'hi'
},
await
retry
(
async
()
=>
{
expect
(
await
browser
.
eval
(
'window.beforeNav'
)).
not
.
toEqual
(
'hi'
)
})
const
html
=
await
browser
.
eval
(
'document.documentElement.innerHTML'
)
...
...
@@ -153,10 +149,8 @@ describe('basePath', () => {
await
browser
.
eval
(
'window.beforeNav = "hi"'
)
await
browser
.
eval
(
`window.next.router.replace("
${
basePath
}
/other-page")`
)
await
check
(()
=>
browser
.
eval
(
'window.beforeNav'
),
{
test
(
content
)
{
return
content
!==
'hi'
},
await
retry
(
async
()
=>
{
expect
(
await
browser
.
eval
(
'window.beforeNav'
)).
not
.
toEqual
(
'hi'
)
})
const
html
=
await
browser
.
eval
(
'document.documentElement.innerHTML'
)
...
...
test/e2e/getserversideprops/test/index.test.ts
View file @
cac2dd80
...
...
@@ -638,13 +638,9 @@ const runTests = (isDev = false, isDeploy = false) => {
await
waitFor
(
500
)
await
browser
.
eval
(
'window.beforeClick = "abc"'
)
await
browser
.
elementByCss
(
'#broken-post'
).
click
()
expect
(
await
check
(()
=>
browser
.
eval
(
'window.beforeClick'
),
{
test
(
v
)
{
return
v
!==
'abc'
},
})
).
toBe
(
true
)
await
retry
(
async
()
=>
{
expect
(
await
browser
.
eval
(
'window.beforeClick'
)).
not
.
toEqual
(
'abc'
)
})
})
it
(
'should always call getServerSideProps without caching'
,
async
()
=>
{
...
...
test/e2e/link-with-api-rewrite/index.test.ts
View file @
cac2dd80
import
{
createNext
,
FileRef
}
from
'e2e-utils'
import
{
NextInstance
}
from
'e2e-utils'
import
{
check
}
from
'next-test-utils'
import
{
retry
}
from
'next-test-utils'
import
{
join
}
from
'path'
import
webdriver
from
'next-webdriver'
...
...
@@ -27,8 +27,8 @@ describe('link-with-api-rewrite', () => {
// unset).
await
browser
.
eval
(
'window.beforeNav = "hi"'
)
await
browser
.
elementById
(
'rewrite'
).
click
()
await
check
(()
=>
browser
.
eval
(
'window.beforeNav'
),
{
test
:
(
content
)
=>
content
!==
'hi'
,
await
retry
(
async
()
=>
{
expect
(
await
browser
.
eval
(
'window.beforeNav'
)).
not
.
toEqual
(
'hi'
)
})
// Check to see that we were in fact navigated to the correct page.
...
...
@@ -54,8 +54,8 @@ describe('link-with-api-rewrite', () => {
// unset).
await
browser
.
eval
(
'window.beforeNav = "hi"'
)
await
browser
.
elementById
(
'direct'
).
click
()
await
check
(()
=>
browser
.
eval
(
'window.beforeNav'
),
{
test
:
(
content
)
=>
content
!==
'hi'
,
await
retry
(
async
()
=>
{
expect
(
await
browser
.
eval
(
'window.beforeNav'
)).
not
.
toEqual
(
'hi'
)
})
// Check to see that we were in fact navigated to the correct page.
...
...
test/e2e/prerender.test.ts
View file @
cac2dd80
...
...
@@ -772,13 +772,9 @@ describe('Prerender', () => {
const
browser
=
await
webdriver
(
next
.
url
,
'/'
)
await
browser
.
eval
(
'window.beforeClick = "abc"'
)
await
browser
.
elementByCss
(
'#broken-post'
).
click
()
expect
(
await
check
(()
=>
browser
.
eval
(
'window.beforeClick'
),
{
test
(
v
)
{
return
v
!==
'abc'
},
})
).
toBe
(
true
)
await
retry
(
async
()
=>
{
expect
(
await
browser
.
eval
(
'window.beforeClick'
)).
not
.
toEqual
(
'abc'
)
})
})
it
(
'should SSR dynamic page with brackets in param as object'
,
async
()
=>
{
...
...
@@ -906,13 +902,9 @@ describe('Prerender', () => {
const
browser
=
await
webdriver
(
next
.
url
,
'/'
)
await
browser
.
eval
(
'window.beforeClick = "abc"'
)
await
browser
.
elementByCss
(
'#broken-at-first-post'
).
click
()
expect
(
await
check
(()
=>
browser
.
eval
(
'window.beforeClick'
),
{
test
(
v
)
{
return
v
!==
'abc'
},
})
).
toBe
(
true
)
await
retry
(
async
()
=>
{
expect
(
await
browser
.
eval
(
'window.beforeClick'
)).
not
.
toEqual
(
'abc'
)
})
const
text
=
await
browser
.
elementByCss
(
'#params'
).
text
()
expect
(
text
).
toMatch
(
/post.*
?
post-999/
)
...
...
test/lib/next-test-utils.ts
View file @
cac2dd80
...
...
@@ -700,7 +700,7 @@ export async function startCleanStaticServer(dir: string) {
*/
export
async
function
check
(
contentFn
:
()
=>
unknown
|
Promise
<
unknown
>
,
regex
:
any
regex
:
boolean
|
number
|
string
|
RegExp
):
Promise
<
boolean
>
{
let
content
:
unknown
let
lastErr
:
unknown
...
...
@@ -712,7 +712,7 @@ export async function check(
if
(
regex
===
content
)
{
return
true
}
}
else
if
(
regex
.
test
(
content
))
{
}
else
if
(
regex
.
test
(
''
+
content
))
{
// found the content
return
true
}
...
...
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