rsnext/test/e2e/app-dir-legacy-edge-runtime-config/index.test.ts
Vincent Voyer e4ff4da7c8
fix(DX): More precise error messages for export const config deprecation (#54492)
Before:
```
Error: `export const config` in /vercel/path0/src/app/api/route.js is deprecated. Please change `runtime` property to segment export config. See https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
```

After:
```
Error: `export const config` in /vercel/path0/src/app/api/route.js is deprecated:
  - Change `config.runtime…` to `export const runtime = "edge"`
  - Change `config.regions…` to `export const preferredRegion = ["us-east-1"]`
Visit https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config for more information.
```

The values proposed in Change.. are the actual ones from the customers, they can just copy paste.

Closes NEXT-1560
2023-08-25 16:25:15 +00:00

34 lines
1,023 B
TypeScript

import { createNextDescribe } from 'e2e-utils'
createNextDescribe(
'app-dir edge runtime config',
{
files: __dirname,
skipStart: true,
skipDeployment: true,
},
({ next, isNextDev }) => {
it('should warn the legacy object config export', async () => {
let error
await next.start().catch((err) => {
error = err
})
if (isNextDev) {
expect(error).not.toBeDefined()
await next.fetch('/legacy-runtime-config')
} else {
expect(error).toBeDefined()
}
expect(next.cliOutput).toContain('Page config in ')
expect(next.cliOutput).toContain(
// the full path is more complex, we only care about this part
'app/legacy-runtime-config/page.js is deprecated. Replace `export const config=…` with the following:'
)
expect(next.cliOutput).toContain('- `export const runtime = "edge"`')
expect(next.cliOutput).toContain(
'- `export const preferredRegion = ["us-east-1"]`'
)
})
}
)