Skip to content

Commit

Permalink
test(fixture): update test fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Mar 20, 2024
1 parent 491f6d8 commit a62330e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
29 changes: 13 additions & 16 deletions test/integration/edge-runtime-module-errors/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
`)
},
Expand All @@ -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()
Expand Down Expand Up @@ -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' }
`)
},
Expand All @@ -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()
Expand Down Expand Up @@ -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' }
`)
},
Expand All @@ -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()
Expand All @@ -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')
})
Expand Down Expand Up @@ -289,7 +286,7 @@ describe('Edge runtime code with imports', () => {
response.headers.set('x-from-runtime', nanoid())
return response
}
export const config = { runtime: 'edge' }
`)
},
Expand Down Expand Up @@ -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' }
`)
},
Expand Down
4 changes: 3 additions & 1 deletion test/integration/edge-runtime-module-errors/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit a62330e

Please sign in to comment.