Skip to content

Commit a2ea7a4

Browse files
authored
Add Test for PR vercel#10037 (vercel#10093)
1 parent 6d2d675 commit a2ea7a4

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Error() {
2+
return <p id="error-p">Error Rendered</p>
3+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
if (typeof window !== 'undefined') {
2+
throw new Error('fail module evaluation')
3+
}
4+
5+
const Index = () => 'hi'
6+
7+
Index.getInitialProps = () => ({})
8+
9+
export default Index
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* eslint-env jest */
2+
/* global jasmine */
3+
import {
4+
nextBuild,
5+
nextServer,
6+
startApp,
7+
stopApp,
8+
waitFor,
9+
} from 'next-test-utils'
10+
import webdriver from 'next-webdriver'
11+
import { join } from 'path'
12+
13+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2
14+
15+
const appDir = join(__dirname, '..')
16+
17+
let appPort
18+
let app
19+
let server
20+
21+
describe('Module Init Error', () => {
22+
beforeAll(async () => {
23+
await nextBuild(appDir)
24+
app = nextServer({
25+
dir: join(__dirname, '../'),
26+
dev: false,
27+
quiet: true,
28+
})
29+
30+
server = await startApp(app)
31+
appPort = server.address().port
32+
})
33+
afterAll(() => stopApp(server))
34+
35+
it('should render error page', async () => {
36+
const browser = await webdriver(appPort, '/')
37+
try {
38+
await waitFor(2000)
39+
const text = await browser.elementByCss('#error-p').text()
40+
expect(text).toBe('Error Rendered')
41+
} finally {
42+
await browser.close()
43+
}
44+
})
45+
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy