@@ -4,29 +4,27 @@ import { createProjectFromWorkspace } from '../../util/createProject';
44import { runSnykCLI } from '../../util/runSnykCLI' ;
55import { fakeServer } from '../../../acceptance/fake-server' ;
66import { isWindowsOperatingSystem } from '../../../utils' ;
7+ import { getAvailableServerPort } from '../../util/getServerPort' ;
78
89jest . setTimeout ( 1000 * 60 * 5 ) ;
910
1011describe ( 'snyk sbom --command (mocked server only)' , ( ) => {
1112 let server ;
1213 let env : Record < string , string > ;
1314
14- beforeAll (
15- ( ) =>
16- new Promise ( ( res ) => {
17- const port = process . env . PORT || process . env . SNYK_PORT || '58588' ;
18- const baseApi = '/api/v1' ;
19- env = {
20- ...process . env ,
21- SNYK_API : 'http://localhost:' + port + baseApi ,
22- SNYK_HOST : 'http://localhost:' + port ,
23- SNYK_TOKEN : '123456789' ,
24- SNYK_DISABLE_ANALYTICS : '1' ,
25- } ;
26- server = fakeServer ( baseApi , env . SNYK_TOKEN ) ;
27- server . listen ( port , res ) ;
28- } ) ,
29- ) ;
15+ beforeAll ( async ( ) => {
16+ const port = await getAvailableServerPort ( process ) ;
17+ const baseApi = '/api/v1' ;
18+ env = {
19+ ...process . env ,
20+ SNYK_API : 'http://localhost:' + port + baseApi ,
21+ SNYK_HOST : 'http://localhost:' + port ,
22+ SNYK_TOKEN : '123456789' ,
23+ SNYK_DISABLE_ANALYTICS : '1' ,
24+ } ;
25+ server = fakeServer ( baseApi , env . SNYK_TOKEN ) ;
26+ await server . listenPromise ( port ) ;
27+ } ) ;
3028
3129 afterEach ( ( ) => {
3230 jest . resetAllMocks ( ) ;
0 commit comments