Skip to content

Commit

Permalink
Code review suggestion: check that Edge APIs have source maps too
Browse files Browse the repository at this point in the history
  • Loading branch information
Schniz committed Jul 6, 2022
1 parent a399024 commit 93e8959
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions test/production/generate-middleware-source-maps/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import path from 'path'
describe('Middleware source maps', () => {
let next: NextInstance

afterEach(() => next.destroy())

it('generates a source map', async () => {
beforeAll(async () => {
next = await createNext({
files: {
'pages/index.js': `
export default function () { return <div>Hello, world!</div> }
`,
'pages/api/edge.js': `
export const config = { runtime: 'experimental-edge' };
export default function (req) {
return new Response("Hello from " + req.url);
}
`,
'middleware.js': `
import { NextResponse } from "next/server";
export default function middleware() {
Expand All @@ -22,12 +26,24 @@ describe('Middleware source maps', () => {
`,
},
})
})
afterAll(() => next.destroy())

it('generates a source map for Middleware', async () => {
const middlewarePath = path.resolve(
next.testDir,
'.next/server/middleware.js'
)
expect(await fs.pathExists(middlewarePath)).toEqual(true)
expect(await fs.pathExists(`${middlewarePath}.map`)).toEqual(true)
})

it('generates a source map for Edge API', async () => {
const edgePath = path.resolve(
next.testDir,
'.next/server/pages/api/edge.js'
)
expect(await fs.pathExists(edgePath)).toEqual(true)
expect(await fs.pathExists(`${edgePath}.map`)).toEqual(true)
})
})

0 comments on commit 93e8959

Please sign in to comment.