Skip to content

Commit b55229f

Browse files
eps1lonhuozhi
authored andcommitted
[test] Use new Redbox matchers in app/ ReactRefreshLogBoxMisc (#76563)
1 parent 0463f45 commit b55229f

File tree

1 file changed

+43
-199
lines changed

1 file changed

+43
-199
lines changed

Diff for: test/development/acceptance-app/ReactRefreshLogBoxMisc.test.ts

+43-199
Original file line numberDiff line numberDiff line change
@@ -3,210 +3,15 @@ import { FileRef, nextTestSetup } from 'e2e-utils'
33
import path from 'path'
44
import { outdent } from 'outdent'
55

6-
// TODO: re-enable these tests after figuring out what is causing
7-
// them to be so unreliable in CI
8-
describe.skip('ReactRefreshLogBox app', () => {
9-
const { next } = nextTestSetup({
6+
describe('ReactRefreshLogBox app', () => {
7+
const { isTurbopack, next } = nextTestSetup({
108
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
119
skipStart: true,
1210
})
1311

14-
test('<Link> with multiple children', async () => {
15-
await using sandbox = await createSandbox(next)
16-
const { session } = sandbox
17-
18-
await session.patch(
19-
'index.js',
20-
outdent`
21-
import Link from 'next/link'
22-
23-
export default function Index() {
24-
return (
25-
<Link href="/">
26-
<p>One</p>
27-
<p>Two</p>
28-
</Link>
29-
)
30-
}
31-
`
32-
)
33-
34-
await session.assertHasRedbox()
35-
expect(await session.getRedboxDescription()).toMatchInlineSnapshot(
36-
`"Error: Multiple children were passed to <Link> with \`href\` of \`/\` but only one child is supported https://nextjs.org/docs/messages/link-multiple-children"`
37-
)
38-
expect(
39-
await session.evaluate(
40-
() =>
41-
(
42-
document
43-
.querySelector('body > nextjs-portal')
44-
.shadowRoot.querySelector(
45-
'#nextjs__container_errors_desc a:nth-of-type(1)'
46-
) as any
47-
).href
48-
)
49-
).toMatch('https://nextjs.org/docs/messages/link-multiple-children')
50-
})
51-
52-
test('<Link> component props errors', async () => {
53-
await using sandbox = await createSandbox(next)
54-
const { session } = sandbox
55-
56-
await session.patch(
57-
'index.js',
58-
outdent`
59-
import Link from 'next/link'
60-
61-
export default function Hello() {
62-
return <Link />
63-
}
64-
`
65-
)
66-
67-
await session.assertHasRedbox()
68-
expect(await session.getRedboxDescription()).toMatchInlineSnapshot(
69-
`"Error: Failed prop type: The prop \`href\` expects a \`string\` or \`object\` in \`<Link>\`, but got \`undefined\` instead."`
70-
)
71-
72-
await session.patch(
73-
'index.js',
74-
outdent`
75-
import Link from 'next/link'
76-
77-
export default function Hello() {
78-
return <Link href="/">Abc</Link>
79-
}
80-
`
81-
)
82-
await session.assertNoRedbox()
83-
84-
await session.patch(
85-
'index.js',
86-
outdent`
87-
import Link from 'next/link'
88-
89-
export default function Hello() {
90-
return (
91-
<Link
92-
href="/"
93-
as="/"
94-
replace={false}
95-
scroll={false}
96-
shallow={false}
97-
passHref={false}
98-
prefetch={false}
99-
>
100-
Abc
101-
</Link>
102-
)
103-
}
104-
`
105-
)
106-
await session.assertNoRedbox()
107-
108-
await session.patch(
109-
'index.js',
110-
outdent`
111-
import Link from 'next/link'
112-
113-
export default function Hello() {
114-
return (
115-
<Link
116-
href="/"
117-
as="/"
118-
replace={true}
119-
scroll={true}
120-
shallow={true}
121-
passHref={true}
122-
prefetch={true}
123-
>
124-
Abc
125-
</Link>
126-
)
127-
}
128-
`
129-
)
130-
await session.assertNoRedbox()
131-
132-
await session.patch(
133-
'index.js',
134-
outdent`
135-
import Link from 'next/link'
136-
137-
export default function Hello() {
138-
return (
139-
<Link
140-
href="/"
141-
as="/"
142-
replace={undefined}
143-
scroll={undefined}
144-
shallow={undefined}
145-
passHref={undefined}
146-
prefetch={undefined}
147-
>
148-
Abc
149-
</Link>
150-
)
151-
}
152-
`
153-
)
154-
await session.assertNoRedbox()
155-
156-
await session.patch(
157-
'index.js',
158-
outdent`
159-
import Link from 'next/link'
160-
161-
export default function Hello() {
162-
return (
163-
<Link
164-
href="/"
165-
as="/"
166-
replace={undefined}
167-
scroll={'oops'}
168-
shallow={undefined}
169-
passHref={undefined}
170-
prefetch={undefined}
171-
>
172-
Abc
173-
</Link>
174-
)
175-
}
176-
`
177-
)
178-
await session.assertHasRedbox()
179-
expect(await session.getRedboxDescription()).toMatchSnapshot()
180-
181-
await session.patch(
182-
'index.js',
183-
outdent`
184-
import Link from 'next/link'
185-
186-
export default function Hello() {
187-
return (
188-
<Link
189-
href={false}
190-
as="/"
191-
replace={undefined}
192-
scroll={'oops'}
193-
shallow={undefined}
194-
passHref={undefined}
195-
prefetch={undefined}
196-
>
197-
Abc
198-
</Link>
199-
)
200-
}
201-
`
202-
)
203-
await session.assertHasRedbox()
204-
expect(await session.getRedboxDescription()).toMatchSnapshot()
205-
})
206-
20712
test('server-side only compilation errors', async () => {
20813
await using sandbox = await createSandbox(next)
209-
const { session } = sandbox
14+
const { browser, session } = sandbox
21015

21116
await session.patch(
21217
'app/page.js',
@@ -226,6 +31,45 @@ describe.skip('ReactRefreshLogBox app', () => {
22631
`
22732
)
22833

229-
await session.assertHasRedbox()
34+
if (isTurbopack) {
35+
await expect(browser).toDisplayRedbox(`
36+
{
37+
"count": 1,
38+
"description": "Ecmascript file had an error",
39+
"environmentLabel": null,
40+
"label": "Build Error",
41+
"source": "./app/page.js (3:23)
42+
Ecmascript file had an error
43+
> 3 | export async function getStaticProps() {
44+
| ^^^^^^^^^^^^^^",
45+
"stack": [],
46+
}
47+
`)
48+
} else {
49+
await expect(browser).toDisplayRedbox(`
50+
{
51+
"count": 1,
52+
"description": "Error: x "getStaticProps" is not supported in app/. Read more: https://nextjs.org/docs/app/building-your-application/data-fetching",
53+
"environmentLabel": null,
54+
"label": "Build Error",
55+
"source": "./app/page.js
56+
Error: x "getStaticProps" is not supported in app/. Read more: https://nextjs.org/docs/app/building-your-application/data-fetching
57+
|
58+
|
59+
,-[3:1]
60+
1 | 'use client'
61+
2 | import myLibrary from 'my-non-existent-library'
62+
3 | export async function getStaticProps() {
63+
: ^^^^^^^^^^^^^^
64+
4 | return {
65+
5 | props: {
66+
6 | result: myLibrary()
67+
\`----
68+
Import trace for requested module:
69+
./app/page.js",
70+
"stack": [],
71+
}
72+
`)
73+
}
23074
})
23175
})

0 commit comments

Comments
 (0)