-
Notifications
You must be signed in to change notification settings - Fork 28.2k
[test] Use new Redbox matchers in app/ ReactRefreshLogBoxMisc #76563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
eps1lon
merged 1 commit into
canary
from
sebbie/02-26-_test_use_new_redbox_matchers_in_app/_reactrefreshlogboxmisc
Feb 27, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -3,210 +3,15 @@ import { FileRef, nextTestSetup } from 'e2e-utils' | |||
import path from 'path' | ||||
import { outdent } from 'outdent' | ||||
|
||||
// TODO: re-enable these tests after figuring out what is causing | ||||
// them to be so unreliable in CI | ||||
describe.skip('ReactRefreshLogBox app', () => { | ||||
const { next } = nextTestSetup({ | ||||
describe('ReactRefreshLogBox app', () => { | ||||
const { isTurbopack, next } = nextTestSetup({ | ||||
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')), | ||||
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 () => { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tested in
|
||||
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 () => { | ||||
await using sandbox = await createSandbox(next) | ||||
const { session } = sandbox | ||||
const { browser, session } = sandbox | ||||
|
||||
await session.patch( | ||||
'app/page.js', | ||||
|
@@ -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": [], | ||||
} | ||||
`) | ||||
} | ||||
}) | ||||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested in
next.js/test/e2e/next-link-errors/next-link-errors.test.ts
Line 64 in aae3692