mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
`url.parse` is deprecated in favor of WHATWG URLs. Almost all tests don't actually test integration with `url.parse`. The remaining places test integration with the Next.js request handler which does accept `url.parse` values. We may deprecate that specific signature in favor of accepting WHATWG URLs instead.
69 lines
1.8 KiB
TypeScript
69 lines
1.8 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('app edge middleware', () => {
|
|
describe('without node.js modules', () => {
|
|
const { next } = nextTestSetup({
|
|
files: {
|
|
'app/page.js': `
|
|
export default function Page() {
|
|
return <p>hello world</p>
|
|
}
|
|
`,
|
|
'app/layout.js': `
|
|
export default function Root({ children }) {
|
|
return (
|
|
<html>
|
|
<body>
|
|
{children}
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|
|
`,
|
|
'middleware.js': `
|
|
import { NextResponse } from 'next/server';
|
|
export async function middleware() {
|
|
return NextResponse.next()
|
|
}
|
|
`,
|
|
},
|
|
})
|
|
it('should not have any errors about using Node.js modules if not present in middleware', async () => {
|
|
expect(next.cliOutput).not.toContain('node-module-in-edge-runtime')
|
|
})
|
|
})
|
|
|
|
describe('with node.js modules', () => {
|
|
const { next } = nextTestSetup({
|
|
files: {
|
|
'app/page.js': `
|
|
export default function Page() {
|
|
return <p>hello world</p>
|
|
}
|
|
`,
|
|
'app/layout.js': `
|
|
export default function Root({ children }) {
|
|
return (
|
|
<html>
|
|
<body>
|
|
{children}
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|
|
`,
|
|
'middleware.js': `
|
|
import { NextResponse } from 'next/server';
|
|
import { URL } from 'url';
|
|
export async function middleware() {
|
|
return NextResponse.next()
|
|
}
|
|
`,
|
|
},
|
|
})
|
|
it('should have errors about using Node.js modules when present in middleware', async () => {
|
|
expect(next.cliOutput).toContain('node-module-in-edge-runtime')
|
|
})
|
|
})
|
|
})
|