Skip to content

Commit ad78237

Browse files
committed
Update test
1 parent 38cfd52 commit ad78237

File tree

3 files changed

+54
-24
lines changed

3 files changed

+54
-24
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { FileRef, nextTestSetup } from 'e2e-utils'
2+
import path from 'path'
3+
4+
describe('app-dir edge SSR invalid reexport', () => {
5+
const { next, isNextDev, skipped } = nextTestSetup({
6+
files: {
7+
'app/export': new FileRef(path.join(__dirname, 'app', 'export')),
8+
'app/export/inherit/page.tsx':
9+
"export { default, runtime, preferredRegion } from '../basic/page'",
10+
},
11+
skipStart: true,
12+
skipDeployment: true,
13+
})
14+
15+
if (skipped) {
16+
return
17+
}
18+
19+
it('should warn or error about the re-export of a pages runtime/preferredRegion config', async () => {
20+
try {
21+
await next.start()
22+
} catch (_) {
23+
// We expect the build to fail
24+
}
25+
26+
if (isNextDev) {
27+
const browser = await next.browser('/export/inherit')
28+
// Turbopack is stricter and disallows reexports completely
29+
// webpack merely warns in the CLI and still serves the page wuthout a redbox
30+
if (process.env.IS_TURBOPACK_TEST) {
31+
await expect(browser).toDisplayRedbox(`
32+
{
33+
"description": "Next.js can't recognize the exported \`preferredRegion\` field in route. It musn't be reexported.",
34+
"environmentLabel": null,
35+
"label": "Build Error",
36+
"source": "./app/export/inherit/page.tsx (1:28)
37+
Next.js can't recognize the exported \`preferredRegion\` field in route. It musn't be reexported.
38+
> 1 | export { default, runtime, preferredRegion } from '../basic/page'
39+
| ^^^^^^^^^^^^^^^",
40+
"stack": [],
41+
}
42+
`)
43+
}
44+
}
45+
46+
expect(next.cliOutput).toInclude(
47+
`Next.js can't recognize the exported \`runtime\` field in`
48+
)
49+
expect(next.cliOutput).toInclude(
50+
`Next.js can't recognize the exported \`preferredRegion\` field in`
51+
)
52+
})
53+
})

test/e2e/app-dir/app-edge/app-edge.test.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,6 @@ describe('app-dir edge SSR', () => {
3535
})
3636

3737
if ((globalThis as any).isNextDev) {
38-
it('should warn about the re-export of a pages runtime/preferredRegion config', async () => {
39-
const logs = []
40-
next.on('stderr', (log) => {
41-
logs.push(log)
42-
})
43-
const appHtml = await next.render('/export/inherit')
44-
expect(appHtml).toContain('<p>Node!</p>')
45-
expect(
46-
logs.some((log) =>
47-
log.includes(
48-
`Next.js can't recognize the exported \`runtime\` field in`
49-
)
50-
)
51-
).toBe(true)
52-
expect(
53-
logs.some((log) =>
54-
log.includes(
55-
`Next.js can't recognize the exported \`preferredRegion\` field in`
56-
)
57-
)
58-
).toBe(true)
59-
})
60-
6138
it('should resolve module without error in edge runtime', async () => {
6239
const logs = []
6340
next.on('stderr', (log) => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default, runtime, preferredRegion } from '../basic/page'
1+
export { default } from '../basic/page'

0 commit comments

Comments
 (0)