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
a0cd5d9a
Unverified
Commit
a0cd5d9a
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 app/ ReactRefreshLogBoxMisc (#76563)
parent
7135484d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
199 deletions
+43
-199
ReactRefreshLogBoxMisc.test.ts
...development/acceptance-app/ReactRefreshLogBoxMisc.test.ts
+43
-199
No files found.
test/development/acceptance-app/ReactRefreshLogBoxMisc.test.ts
View file @
a0cd5d9a
...
@@ -3,210 +3,15 @@ import { FileRef, nextTestSetup } from 'e2e-utils'
...
@@ -3,210 +3,15 @@ import { FileRef, nextTestSetup } from 'e2e-utils'
import
path
from
'path'
import
path
from
'path'
import
{
outdent
}
from
'outdent'
import
{
outdent
}
from
'outdent'
// TODO: re-enable these tests after figuring out what is causing
describe
(
'ReactRefreshLogBox app'
,
()
=>
{
// them to be so unreliable in CI
const
{
isTurbopack
,
next
}
=
nextTestSetup
({
describe
.
skip
(
'ReactRefreshLogBox app'
,
()
=>
{
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
,
})
})
test
(
'<Link> with multiple children'
,
async
()
=>
{
await
using
sandbox
=
await
createSandbox
(
next
)
const
{
session
}
=
sandbox
await
session
.
patch
(
'index.js'
,
outdent
`
import Link from 'next/link'
export default function Index() {
return (
<Link href="/">
<p>One</p>
<p>Two</p>
</Link>
)
}
`
)
await
session
.
assertHasRedbox
()
expect
(
await
session
.
getRedboxDescription
()).
toMatchInlineSnapshot
(
`"Error: Multiple children were passed to <Link> with \`href\` of \`/\` but only one child is supported https://nextjs.org/docs/messages/link-multiple-children"`
)
expect
(
await
session
.
evaluate
(
()
=>
(
document
.
querySelector
(
'body > nextjs-portal'
)
.
shadowRoot
.
querySelector
(
'#nextjs__container_errors_desc a:nth-of-type(1)'
)
as
any
).
href
)
).
toMatch
(
'https://nextjs.org/docs/messages/link-multiple-children'
)
})
test
(
'<Link> component props errors'
,
async
()
=>
{
await
using
sandbox
=
await
createSandbox
(
next
)
const
{
session
}
=
sandbox
await
session
.
patch
(
'index.js'
,
outdent
`
import Link from 'next/link'
export default function Hello() {
return <Link />
}
`
)
await
session
.
assertHasRedbox
()
expect
(
await
session
.
getRedboxDescription
()).
toMatchInlineSnapshot
(
`"Error: Failed prop type: The prop \`href\` expects a \`string\` or \`object\` in \`<Link>\`, but got \`undefined\` instead."`
)
await
session
.
patch
(
'index.js'
,
outdent
`
import Link from 'next/link'
export default function Hello() {
return <Link href="/">Abc</Link>
}
`
)
await
session
.
assertNoRedbox
()
await
session
.
patch
(
'index.js'
,
outdent
`
import Link from 'next/link'
export default function Hello() {
return (
<Link
href="/"
as="/"
replace={false}
scroll={false}
shallow={false}
passHref={false}
prefetch={false}
>
Abc
</Link>
)
}
`
)
await
session
.
assertNoRedbox
()
await
session
.
patch
(
'index.js'
,
outdent
`
import Link from 'next/link'
export default function Hello() {
return (
<Link
href="/"
as="/"
replace={true}
scroll={true}
shallow={true}
passHref={true}
prefetch={true}
>
Abc
</Link>
)
}
`
)
await
session
.
assertNoRedbox
()
await
session
.
patch
(
'index.js'
,
outdent
`
import Link from 'next/link'
export default function Hello() {
return (
<Link
href="/"
as="/"
replace={undefined}
scroll={undefined}
shallow={undefined}
passHref={undefined}
prefetch={undefined}
>
Abc
</Link>
)
}
`
)
await
session
.
assertNoRedbox
()
await
session
.
patch
(
'index.js'
,
outdent
`
import Link from 'next/link'
export default function Hello() {
return (
<Link
href="/"
as="/"
replace={undefined}
scroll={'oops'}
shallow={undefined}
passHref={undefined}
prefetch={undefined}
>
Abc
</Link>
)
}
`
)
await
session
.
assertHasRedbox
()
expect
(
await
session
.
getRedboxDescription
()).
toMatchSnapshot
()
await
session
.
patch
(
'index.js'
,
outdent
`
import Link from 'next/link'
export default function Hello() {
return (
<Link
href={false}
as="/"
replace={undefined}
scroll={'oops'}
shallow={undefined}
passHref={undefined}
prefetch={undefined}
>
Abc
</Link>
)
}
`
)
await
session
.
assertHasRedbox
()
expect
(
await
session
.
getRedboxDescription
()).
toMatchSnapshot
()
})
test
(
'server-side only compilation errors'
,
async
()
=>
{
test
(
'server-side only compilation errors'
,
async
()
=>
{
await
using
sandbox
=
await
createSandbox
(
next
)
await
using
sandbox
=
await
createSandbox
(
next
)
const
{
session
}
=
sandbox
const
{
browser
,
session
}
=
sandbox
await
session
.
patch
(
await
session
.
patch
(
'app/page.js'
,
'app/page.js'
,
...
@@ -226,6 +31,45 @@ describe.skip('ReactRefreshLogBox app', () => {
...
@@ -226,6 +31,45 @@ describe.skip('ReactRefreshLogBox app', () => {
`
`
)
)
await
session
.
assertHasRedbox
()
if
(
isTurbopack
)
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "Ecmascript file had an error",
"environmentLabel": null,
"label": "Build Error",
"source": "./app/page.js (3:23)
Ecmascript file had an error
> 3 | export async function getStaticProps() {
| ^^^^^^^^^^^^^^",
"stack": [],
}
`
)
}
else
{
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count": 1,
"description": "Error: x "getStaticProps" is not supported in app/. Read more: https://nextjs.org/docs/app/building-your-application/data-fetching",
"environmentLabel": null,
"label": "Build Error",
"source": "./app/page.js
Error: x "getStaticProps" is not supported in app/. Read more: https://nextjs.org/docs/app/building-your-application/data-fetching
|
|
,-[3:1]
1 | 'use client'
2 | import myLibrary from 'my-non-existent-library'
3 | export async function getStaticProps() {
: ^^^^^^^^^^^^^^
4 | return {
5 | props: {
6 | result: myLibrary()
\`----
Import trace for requested module:
./app/page.js",
"stack": [],
}
`
)
}
})
})
})
})
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