File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed
test/integration/render-error-on-module-error Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ export default function Error ( ) {
2
+ return < p id = "error-p" > Error Rendered</ p >
3
+ }
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
+ } )
You can’t perform that action at this time.
0 commit comments