@@ -12,6 +12,7 @@ import {
12
12
initNextServerScript ,
13
13
killApp ,
14
14
renderViaHTTP ,
15
+ retry ,
15
16
waitFor ,
16
17
} from 'next-test-utils'
17
18
@@ -134,11 +135,21 @@ describe('required server files', () => {
134
135
} ,
135
136
}
136
137
)
138
+
139
+ if ( process . platform === 'darwin' ) {
140
+ appPort = `http://127.0.0.1:${ appPort } `
141
+ }
137
142
}
138
143
139
144
beforeAll ( async ( ) => {
140
145
await setupNext ( { nextEnv : true , minimalMode : true } )
141
146
} )
147
+
148
+ beforeEach ( ( ) => {
149
+ errors = [ ]
150
+ stderr = ''
151
+ } )
152
+
142
153
afterAll ( async ( ) => {
143
154
await next . destroy ( )
144
155
if ( server ) await killApp ( server )
@@ -958,60 +969,43 @@ describe('required server files', () => {
958
969
} )
959
970
960
971
it ( 'should bubble error correctly for gip page' , async ( ) => {
961
- errors = [ ]
962
972
const res = await fetchViaHTTP ( appPort , '/errors/gip' , { crash : '1' } )
963
973
expect ( res . status ) . toBe ( 500 )
964
974
expect ( await res . text ( ) ) . toBe ( 'Internal Server Error' )
965
975
966
- await check (
967
- ( ) =>
968
- errors . join ( '\n' ) . includes ( 'gip hit an oops' )
969
- ? 'success'
970
- : errors . join ( '\n' ) ,
971
- 'success'
972
- )
976
+ await retry ( ( ) => {
977
+ expect ( errors . join ( '\n' ) ) . toInclude ( 'gip hit an oops' )
978
+ } )
973
979
} )
974
980
975
981
it ( 'should bubble error correctly for gssp page' , async ( ) => {
976
- errors = [ ]
977
982
const res = await fetchViaHTTP ( appPort , '/errors/gssp' , { crash : '1' } )
978
983
expect ( res . status ) . toBe ( 500 )
979
984
expect ( await res . text ( ) ) . toBe ( 'Internal Server Error' )
980
- await check (
981
- ( ) =>
982
- errors . join ( '\n' ) . includes ( 'gssp hit an oops' )
983
- ? 'success'
984
- : errors . join ( '\n' ) ,
985
- 'success'
986
- )
985
+
986
+ await retry ( ( ) => {
987
+ expect ( errors . join ( '\n' ) ) . toInclude ( 'gssp hit an oops' )
988
+ } )
987
989
} )
988
990
989
991
it ( 'should bubble error correctly for gsp page' , async ( ) => {
990
- errors = [ ]
991
992
const res = await fetchViaHTTP ( appPort , '/errors/gsp/crash' )
992
993
expect ( res . status ) . toBe ( 500 )
993
994
expect ( await res . text ( ) ) . toBe ( 'Internal Server Error' )
994
- await check (
995
- ( ) =>
996
- errors . join ( '\n' ) . includes ( 'gsp hit an oops' )
997
- ? 'success'
998
- : errors . join ( '\n' ) ,
999
- 'success'
1000
- )
995
+
996
+ await retry ( ( ) => {
997
+ expect ( errors . join ( '\n' ) ) . toInclude ( 'gsp hit an oops' )
998
+ } )
1001
999
} )
1002
1000
1003
1001
it ( 'should bubble error correctly for API page' , async ( ) => {
1004
- errors = [ ]
1005
1002
const res = await fetchViaHTTP ( appPort , '/api/error' )
1006
1003
expect ( res . status ) . toBe ( 500 )
1007
1004
expect ( await res . text ( ) ) . toBe ( 'Internal Server Error' )
1008
- await check (
1009
- ( ) =>
1010
- errors . join ( '\n' ) . includes ( 'some error from /api/error' )
1011
- ? 'success'
1012
- : errors . join ( '\n' ) ,
1013
- 'success'
1014
- )
1005
+
1006
+ await retry ( ( ) => {
1007
+ expect ( errors . join ( '\n' ) ) . toInclude ( 'some error from /api/error' )
1008
+ } )
1015
1009
} )
1016
1010
1017
1011
it ( 'should normalize optional values correctly for SSP page' , async ( ) => {
@@ -1284,6 +1278,7 @@ describe('required server files', () => {
1284
1278
expect ( envVariables . envFromHost ) . toBe ( 'FOOBAR' )
1285
1279
} )
1286
1280
1281
+ // FIXME: update to not mutate the global state
1287
1282
it ( 'should run middleware correctly (without minimalMode, with wasm)' , async ( ) => {
1288
1283
const standaloneDir = join ( next . testDir , 'standalone' )
1289
1284
0 commit comments