Skip to content

Commit 18a17aa

Browse files
committed
Add test
1 parent 249e054 commit 18a17aa

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ReactNode } from 'react'
2+
export default function Root({ children }: { children: ReactNode }) {
3+
return (
4+
<html>
5+
<body>{children}</body>
6+
</html>
7+
)
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Page() {
2+
return <p>hello world</p>
3+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @type {import('next').NextConfig}
3+
*/
4+
const nextConfig = {}
5+
6+
module.exports = nextConfig
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { nextTestSetup } from 'e2e-utils'
2+
3+
const errorMessage =
4+
'The Proxy "/proxy" must export a `proxy` or a `default` function'
5+
6+
describe('proxy-missing-export', () => {
7+
const { next, isNextDev, skipped } = nextTestSetup({
8+
files: __dirname,
9+
skipDeployment: true,
10+
skipStart: true,
11+
})
12+
13+
if (skipped) {
14+
return
15+
}
16+
17+
it('should error when proxy file is missing a correct export', async () => {
18+
if (isNextDev) {
19+
await next.start().catch(() => {})
20+
// Errors during runtime
21+
await next.browser('/')
22+
expect(next.cliOutput).toContain(errorMessage)
23+
} else {
24+
const { cliOutput } = await next.build()
25+
expect(cliOutput).toContain(errorMessage)
26+
}
27+
})
28+
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Should be proxy, but is middleware which will throw an error.
2+
export function middleware() {
3+
return new Response('Hello, world!')
4+
}

0 commit comments

Comments
 (0)