Unverified Commit d95bc960 authored by OJ Kwon's avatar OJ Kwon Committed by GitHub

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
parent 3234b50f
...@@ -53,12 +53,12 @@ describe('Edge runtime code with imports', () => { ...@@ -53,12 +53,12 @@ describe('Edge runtime code with imports', () => {
init(importStatement) { init(importStatement) {
context.api.write(` context.api.write(`
import { NextResponse } from 'next/server' import { NextResponse } from 'next/server'
export default async function handler(request) { export default async function handler(request) {
const { writeFile } = ${importStatement} const { writeFile } = ${importStatement}
return Response.json({ ok: writeFile() }) return Response.json({ ok: writeFile() })
} }
export const config = { runtime: 'edge' } export const config = { runtime: 'edge' }
`) `)
}, },
...@@ -69,7 +69,7 @@ describe('Edge runtime code with imports', () => { ...@@ -69,7 +69,7 @@ describe('Edge runtime code with imports', () => {
init(importStatement) { init(importStatement) {
context.middleware.write(` context.middleware.write(`
import { NextResponse } from 'next/server' import { NextResponse } from 'next/server'
export async function middleware(request) { export async function middleware(request) {
const { writeFile } = ${importStatement} const { writeFile } = ${importStatement}
return NextResponse.next() return NextResponse.next()
...@@ -129,11 +129,11 @@ describe('Edge runtime code with imports', () => { ...@@ -129,11 +129,11 @@ describe('Edge runtime code with imports', () => {
init(importStatement) { init(importStatement) {
context.api.write(` context.api.write(`
import throwAsync from '../../lib' import throwAsync from '../../lib'
export default async function handler(request) { export default async function handler(request) {
return Response.json({ ok: await throwAsync() }) return Response.json({ ok: await throwAsync() })
} }
export const config = { runtime: 'edge' } export const config = { runtime: 'edge' }
`) `)
}, },
...@@ -145,7 +145,7 @@ describe('Edge runtime code with imports', () => { ...@@ -145,7 +145,7 @@ describe('Edge runtime code with imports', () => {
context.middleware.write(` context.middleware.write(`
import { NextResponse } from 'next/server' import { NextResponse } from 'next/server'
import throwAsync from './lib' import throwAsync from './lib'
export async function middleware(request) { export async function middleware(request) {
await throwAsync() await throwAsync()
return NextResponse.next() return NextResponse.next()
...@@ -216,12 +216,12 @@ describe('Edge runtime code with imports', () => { ...@@ -216,12 +216,12 @@ describe('Edge runtime code with imports', () => {
init(importStatement) { init(importStatement) {
context.api.write(` context.api.write(`
${importStatement} ${importStatement}
export default async function handler(request) { export default async function handler(request) {
new Unknown() new Unknown()
return Response.json({ ok: true }) return Response.json({ ok: true })
} }
export const config = { runtime: 'edge' } export const config = { runtime: 'edge' }
`) `)
}, },
...@@ -233,7 +233,7 @@ describe('Edge runtime code with imports', () => { ...@@ -233,7 +233,7 @@ describe('Edge runtime code with imports', () => {
context.middleware.write(` context.middleware.write(`
import { NextResponse } from 'next/server' import { NextResponse } from 'next/server'
${importStatement} ${importStatement}
export async function middleware(request) { export async function middleware(request) {
new Unknown() new Unknown()
return NextResponse.next() return NextResponse.next()
...@@ -252,12 +252,9 @@ describe('Edge runtime code with imports', () => { ...@@ -252,12 +252,9 @@ describe('Edge runtime code with imports', () => {
const res = await fetchViaHTTP(context.appPort, url) const res = await fetchViaHTTP(context.appPort, url)
expect(res.status).toBe(500) expect(res.status).toBe(500)
const text = await res.text()
await check(async () => { await check(async () => {
expectModuleNotFoundDevError( expectModuleNotFoundDevError(moduleName, importStatement, text)
moduleName,
importStatement,
await res.text()
)
return 'success' return 'success'
}, 'success') }, 'success')
}) })
...@@ -289,7 +286,7 @@ describe('Edge runtime code with imports', () => { ...@@ -289,7 +286,7 @@ describe('Edge runtime code with imports', () => {
response.headers.set('x-from-runtime', nanoid()) response.headers.set('x-from-runtime', nanoid())
return response return response
} }
export const config = { runtime: 'edge' } export const config = { runtime: 'edge' }
`) `)
}, },
...@@ -358,7 +355,7 @@ describe('Edge runtime code with imports', () => { ...@@ -358,7 +355,7 @@ describe('Edge runtime code with imports', () => {
response.headers.set('x-from-runtime', Buffer.isBuffer('a string')) response.headers.set('x-from-runtime', Buffer.isBuffer('a string'))
return response return response
} }
export const config = { runtime: 'edge' } export const config = { runtime: 'edge' }
`) `)
}, },
......
...@@ -73,7 +73,9 @@ export function expectModuleNotFoundProdError( ...@@ -73,7 +73,9 @@ export function expectModuleNotFoundProdError(
) { ) {
const moduleNotSupportedMessage = getUnsupportedModule(moduleName) const moduleNotSupportedMessage = getUnsupportedModule(moduleName)
expect(stripAnsi(output)).not.toContain(moduleNotSupportedMessage) 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) expect(stripAnsi(output)).toContain(moduleNotFoundMessage)
} }
......
...@@ -9537,14 +9537,13 @@ ...@@ -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 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 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 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" "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 Edge API using Buffer polyfill does not throw in dev at runtime", "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 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 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" "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": [ "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 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", "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",
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment