@@ -50,19 +50,17 @@ describe('Client code', () => {
50
50
} ) ;
51
51
52
52
afterAll ( ( done ) => {
53
- proxy . close ( ( ) => {
54
- done ( ) ;
55
- } ) ;
53
+ proxy . close ( done ) ;
56
54
} ) ;
57
55
58
- it ( 'responds with a 200' , ( done ) => {
56
+ it ( 'responds with a 200' , async ( ) => {
59
57
{
60
58
const req = request ( `http://localhost:${ port2 } ` ) ;
61
- req . get ( '/sockjs-node' ) . expect ( 200 , 'Welcome to SockJS!\n' , done ) ;
59
+ await req . get ( '/sockjs-node' ) . expect ( 200 , 'Welcome to SockJS!\n' ) ;
62
60
}
63
61
{
64
62
const req = request ( `http://localhost:${ port1 } ` ) ;
65
- req . get ( '/sockjs-node' ) . expect ( 200 , 'Welcome to SockJS!\n' , done ) ;
63
+ await req . get ( '/sockjs-node' ) . expect ( 200 , 'Welcome to SockJS!\n' ) ;
66
64
}
67
65
} ) ;
68
66
@@ -297,47 +295,34 @@ describe('Client console.log', () => {
297
295
} ,
298
296
] ;
299
297
300
- cases . forEach ( ( { title, options } ) => {
301
- it ( title , ( done ) => {
298
+ for ( const { title, options } of cases ) {
299
+ it ( title , async ( ) => {
302
300
const res = [ ] ;
303
301
const testOptions = Object . assign ( { } , baseOptions , options ) ;
304
302
305
- // TODO: use async/await when Node.js v6 support is dropped
306
- Promise . resolve ( )
307
- . then ( ( ) => {
308
- return new Promise ( ( resolve ) => {
309
- testServer . startAwaitingCompilation ( config , testOptions , resolve ) ;
310
- } ) ;
311
- } )
312
- . then ( ( ) => {
313
- // make sure the previous Promise is not passing along strange arguments to runBrowser
314
- return runBrowser ( ) ;
315
- } )
316
- . then ( ( { page, browser } ) => {
317
- return new Promise ( ( resolve ) => {
318
- page . goto ( `http://localhost:${ port2 } /main` ) ;
319
- page . on ( 'console' , ( { _text } ) => {
320
- res . push ( _text ) ;
321
- } ) ;
322
- // wait for load before closing the browser
323
- page . waitForNavigation ( { waitUntil : 'load' } ) . then ( ( ) => {
324
- page . waitFor ( beforeBrowserCloseDelay ) . then ( ( ) => {
325
- browser . close ( ) . then ( ( ) => {
326
- resolve ( ) ;
327
- } ) ;
328
- } ) ;
329
- } ) ;
330
- } ) ;
331
- } )
332
- . then ( ( ) => {
333
- return new Promise ( ( resolve ) => {
334
- testServer . close ( resolve ) ;
335
- } ) ;
336
- } )
337
- . then ( ( ) => {
338
- expect ( res ) . toMatchSnapshot ( ) ;
339
- done ( ) ;
340
- } ) ;
303
+ // TODO: refactor(hiroppy)
304
+ await new Promise ( ( resolve ) => {
305
+ testServer . startAwaitingCompilation ( config , testOptions , resolve ) ;
306
+ } ) ;
307
+
308
+ const { page, browser } = await runBrowser ( ) ;
309
+
310
+ page . goto ( `http://localhost:${ port2 } /main` ) ;
311
+ page . on ( 'console' , ( { _text } ) => {
312
+ res . push ( _text ) ;
313
+ } ) ;
314
+
315
+ // wait for load before closing the browser
316
+ await page . waitForNavigation ( { waitUntil : 'load' } ) ;
317
+ await page . waitFor ( beforeBrowserCloseDelay ) ;
318
+ await browser . close ( ) ;
319
+
320
+ expect ( res ) . toMatchSnapshot ( ) ;
321
+
322
+ // TODO: refactor(hiroppy)
323
+ await new Promise ( ( resolve ) => {
324
+ testServer . close ( resolve ) ;
325
+ } ) ;
341
326
} ) ;
342
- } ) ;
327
+ }
343
328
} ) ;
0 commit comments