@@ -19,6 +19,7 @@ const _404PageUrl = `http://127.0.0.1:${PORT2}/404`
19
19
20
20
const staticServer = new StaticServer ( PORT , __dirname )
21
21
const staticServer2 = new StaticServer ( PORT2 )
22
+ const staticServerErr = new StaticServer ( PORT )
22
23
23
24
before ( async ( ) => {
24
25
global . expect = expect
@@ -40,6 +41,22 @@ before(async () => {
40
41
await Promise . all ( [ staticServer . listen ( ) , staticServer2 . listen ( ) , launchPuppeteerPromise ] )
41
42
} )
42
43
44
+ describe ( 'Error handling functionality' , ( ) => {
45
+ it ( "Multiple `listen()` invocation" , ( done ) => {
46
+ staticServer . listen ( ) . then ( ( ) => expect ( true ) . to . be . false , err => {
47
+ expect ( err . toString ( ) ) . to . include ( 'ERR_SERVER_ALREADY_LISTEN' )
48
+ done ( )
49
+ } )
50
+ } )
51
+
52
+ it ( "Listen to a busy port" , ( done ) => {
53
+ staticServerErr . listen ( ) . then ( ( ) => expect ( true ) . to . be . false , err => {
54
+ expect ( err . toString ( ) ) . to . include ( `EADDRINUSE` )
55
+ done ( )
56
+ } )
57
+ } )
58
+ } )
59
+
43
60
describe ( 'End-to-end tests using puppeteer' , ( ) => {
44
61
it ( 'Should load mock page as expected and without any error' , async ( ) => {
45
62
const page = ( await browser . pages ( ) ) [ 0 ] ;
@@ -56,7 +73,7 @@ describe('End-to-end tests using puppeteer', () => {
56
73
expect ( response . status ( ) ) . to . equal ( 200 )
57
74
58
75
expect ( response . headers ( ) [ 'content-type' ] ) . to . equal ( 'text/html' )
59
-
76
+
60
77
expect ( await page . title ( ) ) . to . equal ( 'Mock HTML' )
61
78
62
79
expect ( await page . evaluate ( ( ) => [
0 commit comments