@@ -56,9 +56,13 @@ describe("port", () => {
56
56
`options.port should be >= 0 and < 65536`
57
57
) ;
58
58
59
- expect ( errored . message ) . toMatch ( errorMessageRegExp ) ;
60
-
61
- await server . stop ( ) ;
59
+ try {
60
+ expect ( errored . message ) . toMatch ( errorMessageRegExp ) ;
61
+ } catch ( error ) {
62
+ throw error ;
63
+ } finally {
64
+ await server . stop ( ) ;
65
+ }
62
66
63
67
return ;
64
68
}
@@ -73,28 +77,32 @@ describe("port", () => {
73
77
74
78
const { page, browser } = await runBrowser ( ) ;
75
79
76
- const pageErrors = [ ] ;
77
- const consoleMessages = [ ] ;
78
-
79
- page
80
- . on ( "console" , ( message ) => {
81
- consoleMessages . push ( message ) ;
82
- } )
83
- . on ( "pageerror" , ( error ) => {
84
- pageErrors . push ( error ) ;
80
+ try {
81
+ const pageErrors = [ ] ;
82
+ const consoleMessages = [ ] ;
83
+
84
+ page
85
+ . on ( "console" , ( message ) => {
86
+ consoleMessages . push ( message ) ;
87
+ } )
88
+ . on ( "pageerror" , ( error ) => {
89
+ pageErrors . push ( error ) ;
90
+ } ) ;
91
+
92
+ await page . goto ( `http://127.0.0.1:${ address . port } /` , {
93
+ waitUntil : "networkidle0" ,
85
94
} ) ;
86
95
87
- await page . goto ( `http://127.0.0.1:${ address . port } /` , {
88
- waitUntil : "networkidle0" ,
89
- } ) ;
90
-
91
- expect ( consoleMessages . map ( ( message ) => message . text ( ) ) ) . toMatchSnapshot (
92
- "console messages"
93
- ) ;
94
- expect ( pageErrors ) . toMatchSnapshot ( "page errors" ) ;
95
-
96
- await browser . close ( ) ;
97
- await server . stop ( ) ;
96
+ expect (
97
+ consoleMessages . map ( ( message ) => message . text ( ) )
98
+ ) . toMatchSnapshot ( "console messages" ) ;
99
+ expect ( pageErrors ) . toMatchSnapshot ( "page errors" ) ;
100
+ } catch ( error ) {
101
+ throw error ;
102
+ } finally {
103
+ await browser . close ( ) ;
104
+ await server . stop ( ) ;
105
+ }
98
106
99
107
if (
100
108
testedPort === "<not-specified>" ||
0 commit comments