@@ -4,14 +4,14 @@ import * as http from "http"
44import * as https from "https"
55import * as path from "path"
66import { createApp , ensureAddress , handleArgsSocketCatchError , handleServerError } from "../../../src/node/app"
7- import { OptionalString , setDefaults } from "../../../src/node/cli"
7+ import { createDefaultArgs , OptionalString , setDefaults } from "../../../src/node/cli"
88import { generateCertificate } from "../../../src/node/util"
99import { getAvailablePort , tmpdir } from "../../utils/helpers"
1010
1111describe ( "createApp" , ( ) => {
1212 let spy : jest . SpyInstance
1313 let unlinkSpy : jest . SpyInstance
14- let port : number
14+ let port : string
1515 let tmpDirPath : string
1616 let tmpFilePath : string
1717
@@ -29,7 +29,7 @@ describe("createApp", () => {
2929 // then you can spy on those modules methods, like unlink.
3030 // See: https://github.com/aelbore/esbuild-jest/issues/26#issuecomment-893763840
3131 unlinkSpy = jest . spyOn ( promises , "unlink" )
32- port = await getAvailablePort ( )
32+ port = ( await getAvailablePort ( ) ) . toString ( )
3333 } )
3434
3535 afterEach ( ( ) => {
@@ -44,8 +44,8 @@ describe("createApp", () => {
4444
4545 it ( "should return an Express app, a WebSockets Express app and an http server" , async ( ) => {
4646 const defaultArgs = await setDefaults ( {
47+ ...createDefaultArgs ( ) ,
4748 port,
48- _ : [ ] ,
4949 } )
5050 const app = await createApp ( defaultArgs )
5151
@@ -61,8 +61,8 @@ describe("createApp", () => {
6161
6262 it ( "should handle error events on the server" , async ( ) => {
6363 const defaultArgs = await setDefaults ( {
64+ ...createDefaultArgs ( ) ,
6465 port,
65- _ : [ ] ,
6666 } )
6767
6868 const app = await createApp ( defaultArgs )
@@ -82,10 +82,10 @@ describe("createApp", () => {
8282 it ( "should reject errors that happen before the server can listen" , async ( ) => {
8383 // We listen on an invalid port
8484 // causing the app to reject the Promise called at startup
85- const port = 2
85+ const port = "2"
8686 const defaultArgs = await setDefaults ( {
87+ ...createDefaultArgs ( ) ,
8788 port,
88- _ : [ ] ,
8989 } )
9090
9191 async function masterBall ( ) {
@@ -105,7 +105,7 @@ describe("createApp", () => {
105105 it ( "should unlink a socket before listening on the socket" , async ( ) => {
106106 await promises . writeFile ( tmpFilePath , "" )
107107 const defaultArgs = await setDefaults ( {
108- _ : [ ] ,
108+ ... createDefaultArgs ( ) ,
109109 socket : tmpFilePath ,
110110 } )
111111
@@ -119,9 +119,9 @@ describe("createApp", () => {
119119 const testCertificate = await generateCertificate ( "localhost" )
120120 const cert = new OptionalString ( testCertificate . cert )
121121 const defaultArgs = await setDefaults ( {
122+ ...createDefaultArgs ( ) ,
122123 port,
123124 cert,
124- _ : [ ] ,
125125 [ "cert-key" ] : testCertificate . certKey ,
126126 } )
127127 const app = await createApp ( defaultArgs )
0 commit comments