Skip to content

Commit 5de76c2

Browse files
committed
test: adopt new helper
1 parent 2354c45 commit 5de76c2

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

test/jest/acceptance/snyk-sbom/maven-options.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ import { fakeServer } from '../../../acceptance/fake-server';
22
import { runSnykSbomCliCycloneDxJsonForFixture } from './common';
33
import { createProjectFromFixture } from '../../util/createProject';
44
import { runSnykCLI } from '../../util/runSnykCLI';
5-
import { getServerPort } from '../../util/getServerPort';
5+
import {
6+
getAvailableServerPort,
7+
} from '../../util/getServerPort';
68

79
jest.setTimeout(1000 * 60 * 5);
810

911
describe('snyk sbom: maven options (mocked server only)', () => {
1012
let server;
1113
let env: Record<string, string>;
1214

13-
beforeAll((done) => {
14-
const port = getServerPort(process);
15+
beforeAll(async () => {
16+
const port = await getAvailableServerPort(process);
1517
const baseApi = '/api/v1';
1618
env = {
1719
...process.env,
@@ -21,9 +23,7 @@ describe('snyk sbom: maven options (mocked server only)', () => {
2123
SNYK_DISABLE_ANALYTICS: '1',
2224
};
2325
server = fakeServer(baseApi, env.SNYK_TOKEN);
24-
server.listen(port, () => {
25-
done();
26-
});
26+
await server.listenPromise(port);
2727
});
2828

2929
afterEach(() => {

test/jest/acceptance/snyk-sbom/nuget-options.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@ import * as path from 'path';
33
import { fakeServer } from '../../../acceptance/fake-server';
44
import { createProjectFromFixture } from '../../util/createProject';
55
import { runSnykCLI } from '../../util/runSnykCLI';
6-
import { getServerPort } from '../../util/getServerPort';
6+
import {
7+
getAvailableServerPort,
8+
} from '../../util/getServerPort';
79

810
jest.setTimeout(1000 * 60 * 5);
911

1012
describe('snyk sbom: nuget options (mocked server only)', () => {
1113
let server;
1214
let env: Record<string, string>;
1315

14-
beforeAll((done) => {
15-
const port = getServerPort(process);
16+
beforeAll(async () => {
17+
const port = await getAvailableServerPort(process);
1618
const baseApi = '/api/v1';
1719
env = {
1820
...process.env,
@@ -22,9 +24,7 @@ describe('snyk sbom: nuget options (mocked server only)', () => {
2224
SNYK_DISABLE_ANALYTICS: '1',
2325
};
2426
server = fakeServer(baseApi, env.SNYK_TOKEN);
25-
server.listen(port, () => {
26-
done();
27-
});
27+
await server.listenPromise(port);
2828
});
2929

3030
afterEach(() => {

0 commit comments

Comments
 (0)