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
69116fdc
Unverified
Commit
69116fdc
authored
Feb 27, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Feb 27, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] Use new Redbox matchers in pages/ ReactRefreshLogBox-app-doc (#76551)
parent
1c60a25c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
179 additions
and
159 deletions
+179
-159
ReactRefreshLogBox-app-doc.test.ts
...development/acceptance/ReactRefreshLogBox-app-doc.test.ts
+179
-159
No files found.
test/development/acceptance/ReactRefreshLogBox-app-doc.test.ts
View file @
69116fdc
import
{
createSandbox
}
from
'development-sandbox'
import
{
createSandbox
}
from
'development-sandbox'
import
{
FileRef
,
nextTestSetup
}
from
'e2e-utils'
import
{
FileRef
,
nextTestSetup
}
from
'e2e-utils'
import
{
describeVariants
as
describe
}
from
'next-test-utils'
import
{
outdent
}
from
'outdent'
import
{
outdent
}
from
'outdent'
import
path
from
'path'
import
path
from
'path'
describe
.
each
([
'default'
,
'turbo'
])(
describe
(
'ReactRefreshLogBox _app _document'
,
()
=>
{
'ReactRefreshLogBox _app _document %s'
,
const
{
isTurbopack
,
next
}
=
nextTestSetup
({
()
=>
{
const
{
next
}
=
nextTestSetup
({
files
:
new
FileRef
(
path
.
join
(
__dirname
,
'fixtures'
,
'default-template'
)),
files
:
new
FileRef
(
path
.
join
(
__dirname
,
'fixtures'
,
'default-template'
)),
skipStart
:
true
,
skipStart
:
true
,
})
})
...
@@ -17,8 +14,17 @@ describe.each(['default', 'turbo'])(
...
@@ -17,8 +14,17 @@ describe.each(['default', 'turbo'])(
next
,
next
,
new
Map
([[
'pages/_app.js'
,
``
]])
new
Map
([[
'pages/_app.js'
,
``
]])
)
)
const
{
session
}
=
sandbox
const
{
browser
,
session
}
=
sandbox
await
session
.
assertHasRedbox
()
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "Error: The default export is not a React Component in page: "/_app"",
"environmentLabel": null,
"label": "Runtime Error",
"source": null,
"stack": [],
}
`
)
expect
(
await
session
.
getRedboxDescription
()).
toMatchInlineSnapshot
(
expect
(
await
session
.
getRedboxDescription
()).
toMatchInlineSnapshot
(
`"Error: The default export is not a React Component in page: "/_app""`
`"Error: The default export is not a React Component in page: "/_app""`
)
)
...
@@ -40,11 +46,18 @@ describe.each(['default', 'turbo'])(
...
@@ -40,11 +46,18 @@ describe.each(['default', 'turbo'])(
next
,
next
,
new
Map
([[
'pages/_document.js'
,
``
]])
new
Map
([[
'pages/_document.js'
,
``
]])
)
)
const
{
session
}
=
sandbox
const
{
browser
,
session
}
=
sandbox
await
session
.
assertHasRedbox
()
expect
(
await
session
.
getRedboxDescription
()).
toMatchInlineSnapshot
(
await
expect
(
browser
).
toDisplayRedbox
(
`
`"Error: The default export is not a React Component in page: "/_document""`
{
)
"count": 1,
"description": "Error: The default export is not a React Component in page: "/_document"",
"environmentLabel": null,
"label": "Runtime Error",
"source": null,
"stack": [],
}
`
)
await
session
.
patch
(
await
session
.
patch
(
'pages/_document.js'
,
'pages/_document.js'
,
...
@@ -91,25 +104,30 @@ describe.each(['default', 'turbo'])(
...
@@ -91,25 +104,30 @@ describe.each(['default', 'turbo'])(
],
],
])
])
)
)
const
{
session
}
=
sandbox
const
{
browser
,
session
}
=
sandbox
await
session
.
assertHasRedbox
()
const
content
=
await
session
.
getRedboxSource
()
if
(
isTurbopack
)
{
const
source
=
next
.
normalizeTestDirContent
(
content
)
await
expect
(
browser
).
toDisplayRedbox
(
`
if
(
process
.
env
.
TURBOPACK
)
{
{
expect
(
source
).
toMatchInlineSnapshot
(
`
"count": 1,
"./pages/_app.js (2:11)
"description": "Parsing ecmascript source code failed",
"environmentLabel": null,
"label": "Build Error",
"source": "./pages/_app.js (2:11)
Parsing ecmascript source code failed
Parsing ecmascript source code failed
1 | function MyApp({ Component, pageProps }) {
> 2 | return <<Component {...pageProps} />;
> 2 | return <<Component {...pageProps} />;
| ^
| ^",
3 | }
"stack": [],
4 | export default MyApp
}
Expression expected"
`
)
`
)
}
else
{
}
else
{
expect
(
source
).
toMatchInlineSnapshot
(
`
await
expect
(
browser
).
toDisplayRedbox
(
`
"./pages/_app.js
{
"count": 1,
"description": "Error: x Expression expected",
"environmentLabel": null,
"label": "Build Error",
"source": "./pages/_app.js
Error: x Expression expected
Error: x Expression expected
,-[2:1]
,-[2:1]
1 | function MyApp({ Component, pageProps }) {
1 | function MyApp({ Component, pageProps }) {
...
@@ -126,9 +144,10 @@ describe.each(['default', 'turbo'])(
...
@@ -126,9 +144,10 @@ describe.each(['default', 'turbo'])(
3 | }
3 | }
4 | export default MyApp
4 | export default MyApp
\`----
\`----
Caused by:
Caused by:
Syntax Error"
Syntax Error",
"stack": [],
}
`
)
`
)
}
}
...
@@ -177,28 +196,29 @@ describe.each(['default', 'turbo'])(
...
@@ -177,28 +196,29 @@ describe.each(['default', 'turbo'])(
],
],
])
])
)
)
const
{
session
}
=
sandbox
const
{
browser
,
session
}
=
sandbox
await
session
.
assertHasRedbox
()
if
(
isTurbopack
)
{
const
source
=
next
.
normalizeTestDirContent
(
await
expect
(
browser
).
toDisplayRedbox
(
`
await
session
.
getRedboxSource
()
{
)
"count": 1,
if
(
process
.
env
.
TURBOPACK
)
{
"description": "Parsing ecmascript source code failed",
expect
(
source
).
toMatchInlineSnapshot
(
`
"environmentLabel": null,
"./pages/_document.js (3:36)
"label": "Build Error",
"source": "./pages/_document.js (3:36)
Parsing ecmascript source code failed
Parsing ecmascript source code failed
1 | import Document, { Html, Head, Main, NextScript } from 'next/document'
2 |
> 3 | class MyDocument extends Document {{
> 3 | class MyDocument extends Document {{
| ^
| ^",
4 | static async getInitialProps(ctx) {
"stack": [],
5 | const initialProps = await Document.getInitialProps(ctx)
}
6 | return { ...initialProps }
Unexpected token \`{\`. Expected identifier, string literal, numeric literal or [ for the computed key"
`
)
`
)
}
else
{
}
else
{
expect
(
source
).
toMatchInlineSnapshot
(
`
await
expect
(
browser
).
toDisplayRedbox
(
`
"./pages/_document.js
{
"count": 1,
"description": "Error: x Unexpected token \`{\`. Expected identifier, string literal, numeric literal or [ for the computed key",
"environmentLabel": null,
"label": "Build Error",
"source": "./pages/_document.js
Error: x Unexpected token \`{\`. Expected identifier, string literal, numeric literal or [ for the computed key
Error: x Unexpected token \`{\`. Expected identifier, string literal, numeric literal or [ for the computed key
,-[3:1]
,-[3:1]
1 | import Document, { Html, Head, Main, NextScript } from 'next/document'
1 | import Document, { Html, Head, Main, NextScript } from 'next/document'
...
@@ -209,9 +229,10 @@ describe.each(['default', 'turbo'])(
...
@@ -209,9 +229,10 @@ describe.each(['default', 'turbo'])(
5 | const initialProps = await Document.getInitialProps(ctx)
5 | const initialProps = await Document.getInitialProps(ctx)
6 | return { ...initialProps }
6 | return { ...initialProps }
\`----
\`----
Caused by:
Caused by:
Syntax Error"
Syntax Error",
"stack": [],
}
`
)
`
)
}
}
...
@@ -244,5 +265,4 @@ describe.each(['default', 'turbo'])(
...
@@ -244,5 +265,4 @@ describe.each(['default', 'turbo'])(
)
)
await
session
.
assertNoRedbox
()
await
session
.
assertNoRedbox
()
})
})
}
})
)
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