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
5d53fd00
Unverified
Commit
5d53fd00
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/ service-side-dev-errors (#76779)
parent
f5f5be6b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
219 additions
and
15 deletions
+219
-15
index.test.js
test/integration/server-side-dev-errors/test/index.test.js
+219
-15
No files found.
test/integration/server-side-dev-errors/test/index.test.js
View file @
5d53fd00
...
@@ -4,12 +4,10 @@ import fs from 'fs/promises'
...
@@ -4,12 +4,10 @@ import fs from 'fs/promises'
import
{
join
}
from
'path'
import
{
join
}
from
'path'
import
webdriver
from
'next-webdriver'
import
webdriver
from
'next-webdriver'
import
{
import
{
assertHasRedbox
,
killApp
,
killApp
,
findPort
,
findPort
,
launchApp
,
launchApp
,
retry
,
retry
,
getRedboxSource
,
assertNoRedbox
,
assertNoRedbox
,
}
from
'next-test-utils'
}
from
'next-test-utils'
import
stripAnsi
from
'strip-ansi'
import
stripAnsi
from
'strip-ansi'
...
@@ -87,9 +85,38 @@ describe('server-side dev errors', () => {
...
@@ -87,9 +85,38 @@ describe('server-side dev errors', () => {
'
\
n> 6 | missingVar;return {'
'
\
n> 6 | missingVar;return {'
)
)
await
assertHasRedbox
(
browser
)
if
(
isTurbopack
)
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "../../test/integration/server-side-dev-errors/pages/gsp.js (6:3) @ getStaticProps
> 6 | missingVar;return {
| ^",
"stack": [
"getStaticProps ../../test/integration/server-side-dev-errors/pages/gsp.js (6:3)",
],
}
`
)
}
else
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/gsp.js (6:3) @ getStaticProps
> 6 | missingVar;return {
| ^",
"stack": [
"getStaticProps pages/gsp.js (6:3)",
],
}
`
)
}
expect
(
await
getRedboxSource
(
browser
)).
toContain
(
'missingVar'
)
await
fs
.
writeFile
(
gspPage
,
content
,
{
flush
:
true
})
await
fs
.
writeFile
(
gspPage
,
content
,
{
flush
:
true
})
await
assertNoRedbox
(
browser
)
await
assertNoRedbox
(
browser
)
}
finally
{
}
finally
{
...
@@ -137,9 +164,38 @@ describe('server-side dev errors', () => {
...
@@ -137,9 +164,38 @@ describe('server-side dev errors', () => {
'
\
n> 6 | missingVar;return {'
'
\
n> 6 | missingVar;return {'
)
)
await
assertHasRedbox
(
browser
)
if
(
isTurbopack
)
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "../../test/integration/server-side-dev-errors/pages/gssp.js (6:3) @ getServerSideProps
> 6 | missingVar;return {
| ^",
"stack": [
"getServerSideProps ../../test/integration/server-side-dev-errors/pages/gssp.js (6:3)",
],
}
`
)
}
else
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/gssp.js (6:3) @ getServerSideProps
> 6 | missingVar;return {
| ^",
"stack": [
"getServerSideProps pages/gssp.js (6:3)",
],
}
`
)
}
expect
(
await
getRedboxSource
(
browser
)).
toContain
(
'missingVar'
)
await
fs
.
writeFile
(
gsspPage
,
content
)
await
fs
.
writeFile
(
gsspPage
,
content
)
await
assertNoRedbox
(
browser
)
await
assertNoRedbox
(
browser
)
}
finally
{
}
finally
{
...
@@ -187,11 +243,39 @@ describe('server-side dev errors', () => {
...
@@ -187,11 +243,39 @@ describe('server-side dev errors', () => {
'
\
n> 6 | missingVar;return {'
'
\
n> 6 | missingVar;return {'
)
)
await
assertHasRedbox
(
browser
)
if
(
isTurbopack
)
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "../../test/integration/server-side-dev-errors/pages/blog/[slug].js (6:3) @ getServerSideProps
> 6 | missingVar;return {
| ^",
"stack": [
"getServerSideProps ../../test/integration/server-side-dev-errors/pages/blog/[slug].js (6:3)",
],
}
`
)
}
else
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/blog/[slug].js (6:3) @ getServerSideProps
> 6 | missingVar;return {
| ^",
"stack": [
"getServerSideProps pages/blog/[slug].js (6:3)",
],
}
`
)
}
expect
(
await
getRedboxSource
(
browser
)).
toContain
(
'missingVar'
)
await
fs
.
writeFile
(
dynamicGsspPage
,
content
)
await
fs
.
writeFile
(
dynamicGsspPage
,
content
)
await
assertHasRedbox
(
browser
)
}
finally
{
}
finally
{
await
fs
.
writeFile
(
dynamicGsspPage
,
content
)
await
fs
.
writeFile
(
dynamicGsspPage
,
content
)
}
}
...
@@ -237,11 +321,71 @@ describe('server-side dev errors', () => {
...
@@ -237,11 +321,71 @@ describe('server-side dev errors', () => {
"
\n
> 2 | missingVar;res.status(200).json({ hello: 'world' })"
"
\n
> 2 | missingVar;res.status(200).json({ hello: 'world' })"
)
)
await
assertHasRedbox
(
browser
)
if
(
isTurbopack
)
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "../../test/integration/server-side-dev-errors/pages/api/hello.js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ hello: 'world' })
| ^",
"stack": [
"handler ../../test/integration/server-side-dev-errors/pages/api/hello.js (2:3)",
],
}
`
)
}
else
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/api/hello.js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ hello: 'world' })
| ^",
"stack": [
"handler pages/api/hello.js (2:3)",
],
}
`
)
}
expect
(
await
getRedboxSource
(
browser
)).
toContain
(
'missingVar'
)
await
fs
.
writeFile
(
apiPage
,
content
)
await
fs
.
writeFile
(
apiPage
,
content
)
await
assertHasRedbox
(
browser
)
if
(
isTurbopack
)
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "../../test/integration/server-side-dev-errors/pages/api/hello.js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ hello: 'world' })
| ^",
"stack": [
"handler ../../test/integration/server-side-dev-errors/pages/api/hello.js (2:3)",
],
}
`
)
}
else
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/api/hello.js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ hello: 'world' })
| ^",
"stack": [
"handler pages/api/hello.js (2:3)",
],
}
`
)
}
}
finally
{
}
finally
{
await
fs
.
writeFile
(
apiPage
,
content
)
await
fs
.
writeFile
(
apiPage
,
content
)
}
}
...
@@ -289,11 +433,71 @@ describe('server-side dev errors', () => {
...
@@ -289,11 +433,71 @@ describe('server-side dev errors', () => {
'
\
n> 2 | missingVar;res.status(200).json({ slug: req.query.slug })'
'
\
n> 2 | missingVar;res.status(200).json({ slug: req.query.slug })'
)
)
await
assertHasRedbox
(
browser
)
if
(
isTurbopack
)
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "../../test/integration/server-side-dev-errors/pages/api/blog/[slug].js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ slug: req.query.slug })
| ^",
"stack": [
"handler ../../test/integration/server-side-dev-errors/pages/api/blog/[slug].js (2:3)",
],
}
`
)
}
else
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/api/blog/[slug].js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ slug: req.query.slug })
| ^",
"stack": [
"handler pages/api/blog/[slug].js (2:3)",
],
}
`
)
}
expect
(
await
getRedboxSource
(
browser
)).
toContain
(
'missingVar'
)
await
fs
.
writeFile
(
dynamicApiPage
,
content
)
await
fs
.
writeFile
(
dynamicApiPage
,
content
)
await
assertHasRedbox
(
browser
)
if
(
isTurbopack
)
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "../../test/integration/server-side-dev-errors/pages/api/blog/[slug].js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ slug: req.query.slug })
| ^",
"stack": [
"handler ../../test/integration/server-side-dev-errors/pages/api/blog/[slug].js (2:3)",
],
}
`
)
}
else
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "ReferenceError: missingVar is not defined",
"environmentLabel": null,
"label": "Runtime Error",
"source": "pages/api/blog/[slug].js (2:3) @ handler
> 2 | missingVar;res.status(200).json({ slug: req.query.slug })
| ^",
"stack": [
"handler pages/api/blog/[slug].js (2:3)",
],
}
`
)
}
}
finally
{
}
finally
{
await
fs
.
writeFile
(
dynamicApiPage
,
content
)
await
fs
.
writeFile
(
dynamicApiPage
,
content
)
}
}
...
...
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