test(fixture): update test fixture (#63498)
### What Followup for https://github.com/vercel/next.js/pull/63491, adjust fixture setup to work with turbopack. Closes PACK-2790
This commit is contained in:
parent
3234b50f8f
commit
d95bc960c7
3 changed files with 18 additions and 20 deletions
|
@ -53,12 +53,12 @@ describe('Edge runtime code with imports', () => {
|
|||
init(importStatement) {
|
||||
context.api.write(`
|
||||
import { NextResponse } from 'next/server'
|
||||
|
||||
|
||||
export default async function handler(request) {
|
||||
const { writeFile } = ${importStatement}
|
||||
return Response.json({ ok: writeFile() })
|
||||
}
|
||||
|
||||
|
||||
export const config = { runtime: 'edge' }
|
||||
`)
|
||||
},
|
||||
|
@ -69,7 +69,7 @@ describe('Edge runtime code with imports', () => {
|
|||
init(importStatement) {
|
||||
context.middleware.write(`
|
||||
import { NextResponse } from 'next/server'
|
||||
|
||||
|
||||
export async function middleware(request) {
|
||||
const { writeFile } = ${importStatement}
|
||||
return NextResponse.next()
|
||||
|
@ -129,11 +129,11 @@ describe('Edge runtime code with imports', () => {
|
|||
init(importStatement) {
|
||||
context.api.write(`
|
||||
import throwAsync from '../../lib'
|
||||
|
||||
|
||||
export default async function handler(request) {
|
||||
return Response.json({ ok: await throwAsync() })
|
||||
}
|
||||
|
||||
|
||||
export const config = { runtime: 'edge' }
|
||||
`)
|
||||
},
|
||||
|
@ -145,7 +145,7 @@ describe('Edge runtime code with imports', () => {
|
|||
context.middleware.write(`
|
||||
import { NextResponse } from 'next/server'
|
||||
import throwAsync from './lib'
|
||||
|
||||
|
||||
export async function middleware(request) {
|
||||
await throwAsync()
|
||||
return NextResponse.next()
|
||||
|
@ -216,12 +216,12 @@ describe('Edge runtime code with imports', () => {
|
|||
init(importStatement) {
|
||||
context.api.write(`
|
||||
${importStatement}
|
||||
|
||||
|
||||
export default async function handler(request) {
|
||||
new Unknown()
|
||||
return Response.json({ ok: true })
|
||||
}
|
||||
|
||||
|
||||
export const config = { runtime: 'edge' }
|
||||
`)
|
||||
},
|
||||
|
@ -233,7 +233,7 @@ describe('Edge runtime code with imports', () => {
|
|||
context.middleware.write(`
|
||||
import { NextResponse } from 'next/server'
|
||||
${importStatement}
|
||||
|
||||
|
||||
export async function middleware(request) {
|
||||
new Unknown()
|
||||
return NextResponse.next()
|
||||
|
@ -252,12 +252,9 @@ describe('Edge runtime code with imports', () => {
|
|||
const res = await fetchViaHTTP(context.appPort, url)
|
||||
expect(res.status).toBe(500)
|
||||
|
||||
const text = await res.text()
|
||||
await check(async () => {
|
||||
expectModuleNotFoundDevError(
|
||||
moduleName,
|
||||
importStatement,
|
||||
await res.text()
|
||||
)
|
||||
expectModuleNotFoundDevError(moduleName, importStatement, text)
|
||||
return 'success'
|
||||
}, 'success')
|
||||
})
|
||||
|
@ -289,7 +286,7 @@ describe('Edge runtime code with imports', () => {
|
|||
response.headers.set('x-from-runtime', nanoid())
|
||||
return response
|
||||
}
|
||||
|
||||
|
||||
export const config = { runtime: 'edge' }
|
||||
`)
|
||||
},
|
||||
|
@ -358,7 +355,7 @@ describe('Edge runtime code with imports', () => {
|
|||
response.headers.set('x-from-runtime', Buffer.isBuffer('a string'))
|
||||
return response
|
||||
}
|
||||
|
||||
|
||||
export const config = { runtime: 'edge' }
|
||||
`)
|
||||
},
|
||||
|
|
|
@ -73,7 +73,9 @@ export function expectModuleNotFoundProdError(
|
|||
) {
|
||||
const moduleNotSupportedMessage = getUnsupportedModule(moduleName)
|
||||
expect(stripAnsi(output)).not.toContain(moduleNotSupportedMessage)
|
||||
const moduleNotFoundMessage = getModuleNotFound(moduleName)
|
||||
const moduleNotFoundMessage = process.env.TURBOPACK
|
||||
? `Error: Cannot find module '${moduleName}'`
|
||||
: getModuleNotFound(moduleName)
|
||||
expect(stripAnsi(output)).toContain(moduleNotFoundMessage)
|
||||
}
|
||||
|
||||
|
|
|
@ -9537,14 +9537,13 @@
|
|||
"Edge runtime code with imports Edge API dynamically importing node.js module development mode throws unsupported module error in dev at runtime and highlights the faulty line",
|
||||
"Edge runtime code with imports Middleware dynamically importing node.js module development mode throws unsupported module error in dev at runtime and highlights the faulty line",
|
||||
"Edge runtime code with imports Edge API dynamically importing node.js module in a lib development mode throws unsupported module error in dev at runtime and highlights the faulty line",
|
||||
"Edge runtime code with imports Middleware dynamically importing node.js module in a lib development mode throws unsupported module error in dev at runtime and highlights the faulty line"
|
||||
],
|
||||
"failed": [
|
||||
"Edge runtime code with imports Middleware dynamically importing node.js module in a lib development mode throws unsupported module error in dev at runtime and highlights the faulty line",
|
||||
"Edge runtime code with imports Edge API using Buffer polyfill does not throw in dev at runtime",
|
||||
"Edge runtime code with imports Middleware using Buffer polyfill does not throw in dev at runtime",
|
||||
"Edge runtime code with imports Edge API statically importing 3rd party module throws not-found module error in dev at runtime and highlights the faulty line",
|
||||
"Edge runtime code with imports Middleware statically importing 3rd party module throws not-found module error in dev at runtime and highlights the faulty line"
|
||||
],
|
||||
"failed": [],
|
||||
"pending": [
|
||||
"Edge runtime code with imports Edge API dynamically importing node.js module in a lib production mode throws unsupported module error in production at runtime and prints error on logs",
|
||||
"Edge runtime code with imports Edge API dynamically importing node.js module production mode throws unsupported module error in production at runtime and prints error on logs",
|
||||
|
|
Loading…
Reference in a new issue