Unverified Commit d26716bb authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Update test snapshots for alternative bundler [4/n] (#76578)

Test Plan: `pnpm test-dev-rspack
test/development/acceptance/server-component-compiler-errors-in-pages.test.ts`
passes
parent 80fbbc20
...@@ -3,6 +3,8 @@ import { nextTestSetup } from 'e2e-utils' ...@@ -3,6 +3,8 @@ import { nextTestSetup } from 'e2e-utils'
import { createSandbox } from 'development-sandbox' import { createSandbox } from 'development-sandbox'
import { outdent } from 'outdent' import { outdent } from 'outdent'
const isRspack = process.env.NEXT_RSPACK !== undefined
const initialFiles = new Map([ const initialFiles = new Map([
['app/_.js', ''], // app dir need to exists, otherwise the SWC RSC checks will not run ['app/_.js', ''], // app dir need to exists, otherwise the SWC RSC checks will not run
[ [
...@@ -62,25 +64,46 @@ describe('Error Overlay for server components compiler errors in pages', () => { ...@@ -62,25 +64,46 @@ describe('Error Overlay for server components compiler errors in pages', () => {
You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components" You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components"
`) `)
} else if (isRspack) {
expect(
takeUpToString(
next.normalizeTestDirContent(await session.getRedboxSource()),
'----'
)
).toMatchInlineSnapshot(`
"./components/Comp.js
× Module build failed:
╰─▶ × Error: x You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-
│ | your-application/rendering/server-components
│ |
│ |
│ ,-[1:1]
│ 1 | import { cookies } from 'next/headers'
│ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│ 2 |
│ 3 | export default function Page() {
│ 4 | return <p>hello world</p>
│ \`----"
`)
} else { } else {
expect(next.normalizeTestDirContent(await session.getRedboxSource())) expect(next.normalizeTestDirContent(await session.getRedboxSource()))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"./components/Comp.js "./components/Comp.js
Error: x You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building- Error: x You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-
| your-application/rendering/server-components | your-application/rendering/server-components
| |
| |
,-[1:1] ,-[1:1]
1 | import { cookies } from 'next/headers' 1 | import { cookies } from 'next/headers'
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | 2 |
3 | export default function Page() { 3 | export default function Page() {
4 | return <p>hello world</p> 4 | return <p>hello world</p>
\`---- \`----
Import trace for requested module: Import trace for requested module:
./components/Comp.js ./components/Comp.js
./pages/index.js" ./pages/index.js"
`) `)
} }
}) })
...@@ -118,6 +141,27 @@ describe('Error Overlay for server components compiler errors in pages', () => { ...@@ -118,6 +141,27 @@ describe('Error Overlay for server components compiler errors in pages', () => {
You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components" You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components"
`) `)
} else if (isRspack) {
expect(
takeUpToString(
next.normalizeTestDirContent(await session.getRedboxSource()),
'----'
)
).toMatchInlineSnapshot(`
"./components/Comp.js
× Module build failed:
╰─▶ × Error: x You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-
│ | application/rendering/server-components
│ |
│ |
│ ,-[1:1]
│ 1 | import 'server-only'
│ : ^^^^^^^^^^^^^^^^^^^^
│ 2 |
│ 3 | export default function Page() {
│ 4 | return 'hello world'
│ \`----"
`)
} else { } else {
expect( expect(
takeUpToString( takeUpToString(
...@@ -125,21 +169,21 @@ describe('Error Overlay for server components compiler errors in pages', () => { ...@@ -125,21 +169,21 @@ describe('Error Overlay for server components compiler errors in pages', () => {
'Import trace for requested module:' 'Import trace for requested module:'
) )
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
"./components/Comp.js "./components/Comp.js
Error: x You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your- Error: x You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-
| application/rendering/server-components | application/rendering/server-components
| |
| |
,-[1:1] ,-[1:1]
1 | import 'server-only' 1 | import 'server-only'
: ^^^^^^^^^^^^^^^^^^^^ : ^^^^^^^^^^^^^^^^^^^^
2 | 2 |
3 | export default function Page() { 3 | export default function Page() {
4 | return 'hello world' 4 | return 'hello world'
\`---- \`----
Import trace for requested module:" Import trace for requested module:"
`) `)
} }
}) })
...@@ -176,6 +220,27 @@ describe('Error Overlay for server components compiler errors in pages', () => { ...@@ -176,6 +220,27 @@ describe('Error Overlay for server components compiler errors in pages', () => {
You're importing a component that needs "after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components" You're importing a component that needs "after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components"
`) `)
} else if (isRspack) {
expect(
takeUpToString(
next.normalizeTestDirContent(await session.getRedboxSource()),
'----'
)
).toMatchInlineSnapshot(`
"./components/Comp.js
× Module build failed:
╰─▶ × Error: x You're importing a component that needs "after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-
│ | application/rendering/server-components
│ |
│ |
│ ,-[1:1]
│ 1 | import { after } from 'next/server'
│ : ^^^^^
│ 2 |
│ 3 | export default function Page() {
│ 4 | return 'hello world'
│ \`----"
`)
} else { } else {
expect( expect(
takeUpToString( takeUpToString(
...@@ -183,20 +248,20 @@ describe('Error Overlay for server components compiler errors in pages', () => { ...@@ -183,20 +248,20 @@ describe('Error Overlay for server components compiler errors in pages', () => {
'Import trace for requested module:' 'Import trace for requested module:'
) )
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
"./components/Comp.js "./components/Comp.js
Error: x You're importing a component that needs "after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your- Error: x You're importing a component that needs "after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-
| application/rendering/server-components | application/rendering/server-components
| |
| |
,-[1:1] ,-[1:1]
1 | import { after } from 'next/server' 1 | import { after } from 'next/server'
: ^^^^^ : ^^^^^
2 | 2 |
3 | export default function Page() { 3 | export default function Page() {
4 | return 'hello world' 4 | return 'hello world'
\`---- \`----
Import trace for requested module:" Import trace for requested module:"
`) `)
} }
}) })
...@@ -241,7 +306,7 @@ describe('Error Overlay for server components compiler errors in pages', () => { ...@@ -241,7 +306,7 @@ describe('Error Overlay for server components compiler errors in pages', () => {
'components/Comp.js', 'components/Comp.js',
outdent` outdent`
import { ${api} } from 'next/cache' import { ${api} } from 'next/cache'
export default function Page() { export default function Page() {
return 'hello world' return 'hello world'
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment