diff --git a/test/integration/edge-runtime-module-errors/test/index.test.js b/test/integration/edge-runtime-module-errors/test/index.test.js index 0155940bbe8a8..f22d2fbfb3c4f 100644 --- a/test/integration/edge-runtime-module-errors/test/index.test.js +++ b/test/integration/edge-runtime-module-errors/test/index.test.js @@ -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' } `) }, diff --git a/test/integration/edge-runtime-module-errors/test/utils.js b/test/integration/edge-runtime-module-errors/test/utils.js index 291e1f51a9468..83e07121a9383 100644 --- a/test/integration/edge-runtime-module-errors/test/utils.js +++ b/test/integration/edge-runtime-module-errors/test/utils.js @@ -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) }