Skip to content

Commit d95bc96

Browse files
authored
test(fixture): update test fixture (vercel#63498)
### What Followup for vercel#63491, adjust fixture setup to work with turbopack. Closes PACK-2790
1 parent 3234b50 commit d95bc96

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

test/integration/edge-runtime-module-errors/test/index.test.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ describe('Edge runtime code with imports', () => {
5353
init(importStatement) {
5454
context.api.write(`
5555
import { NextResponse } from 'next/server'
56-
56+
5757
export default async function handler(request) {
5858
const { writeFile } = ${importStatement}
5959
return Response.json({ ok: writeFile() })
6060
}
61-
61+
6262
export const config = { runtime: 'edge' }
6363
`)
6464
},
@@ -69,7 +69,7 @@ describe('Edge runtime code with imports', () => {
6969
init(importStatement) {
7070
context.middleware.write(`
7171
import { NextResponse } from 'next/server'
72-
72+
7373
export async function middleware(request) {
7474
const { writeFile } = ${importStatement}
7575
return NextResponse.next()
@@ -129,11 +129,11 @@ describe('Edge runtime code with imports', () => {
129129
init(importStatement) {
130130
context.api.write(`
131131
import throwAsync from '../../lib'
132-
132+
133133
export default async function handler(request) {
134134
return Response.json({ ok: await throwAsync() })
135135
}
136-
136+
137137
export const config = { runtime: 'edge' }
138138
`)
139139
},
@@ -145,7 +145,7 @@ describe('Edge runtime code with imports', () => {
145145
context.middleware.write(`
146146
import { NextResponse } from 'next/server'
147147
import throwAsync from './lib'
148-
148+
149149
export async function middleware(request) {
150150
await throwAsync()
151151
return NextResponse.next()
@@ -216,12 +216,12 @@ describe('Edge runtime code with imports', () => {
216216
init(importStatement) {
217217
context.api.write(`
218218
${importStatement}
219-
219+
220220
export default async function handler(request) {
221221
new Unknown()
222222
return Response.json({ ok: true })
223223
}
224-
224+
225225
export const config = { runtime: 'edge' }
226226
`)
227227
},
@@ -233,7 +233,7 @@ describe('Edge runtime code with imports', () => {
233233
context.middleware.write(`
234234
import { NextResponse } from 'next/server'
235235
${importStatement}
236-
236+
237237
export async function middleware(request) {
238238
new Unknown()
239239
return NextResponse.next()
@@ -252,12 +252,9 @@ describe('Edge runtime code with imports', () => {
252252
const res = await fetchViaHTTP(context.appPort, url)
253253
expect(res.status).toBe(500)
254254

255+
const text = await res.text()
255256
await check(async () => {
256-
expectModuleNotFoundDevError(
257-
moduleName,
258-
importStatement,
259-
await res.text()
260-
)
257+
expectModuleNotFoundDevError(moduleName, importStatement, text)
261258
return 'success'
262259
}, 'success')
263260
})
@@ -289,7 +286,7 @@ describe('Edge runtime code with imports', () => {
289286
response.headers.set('x-from-runtime', nanoid())
290287
return response
291288
}
292-
289+
293290
export const config = { runtime: 'edge' }
294291
`)
295292
},
@@ -358,7 +355,7 @@ describe('Edge runtime code with imports', () => {
358355
response.headers.set('x-from-runtime', Buffer.isBuffer('a string'))
359356
return response
360357
}
361-
358+
362359
export const config = { runtime: 'edge' }
363360
`)
364361
},

test/integration/edge-runtime-module-errors/test/utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export function expectModuleNotFoundProdError(
7373
) {
7474
const moduleNotSupportedMessage = getUnsupportedModule(moduleName)
7575
expect(stripAnsi(output)).not.toContain(moduleNotSupportedMessage)
76-
const moduleNotFoundMessage = getModuleNotFound(moduleName)
76+
const moduleNotFoundMessage = process.env.TURBOPACK
77+
? `Error: Cannot find module '${moduleName}'`
78+
: getModuleNotFound(moduleName)
7779
expect(stripAnsi(output)).toContain(moduleNotFoundMessage)
7880
}
7981

test/turbopack-dev-tests-manifest.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9537,14 +9537,13 @@
95379537
"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",
95389538
"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",
95399539
"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",
9540-
"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"
9541-
],
9542-
"failed": [
9540+
"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",
95439541
"Edge runtime code with imports Edge API using Buffer polyfill does not throw in dev at runtime",
95449542
"Edge runtime code with imports Middleware using Buffer polyfill does not throw in dev at runtime",
95459543
"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",
95469544
"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"
95479545
],
9546+
"failed": [],
95489547
"pending": [
95499548
"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",
95509549
"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",

0 commit comments

Comments
 (0)