Skip to content

Commit f96372a

Browse files
Run tests concurrently (#1067)
1 parent 30bea9e commit f96372a

25 files changed

+276
-269
lines changed

docs/modules/cassandra.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ npm install @testcontainers/cassandra --save-dev
2121
<!--/codeinclude-->
2222

2323
<!--codeinclude-->
24-
[With custom datacenter / rack](../../packages/modules/cassandra/src/cassandra-container.test.ts) inside_block:customDataSenterAndRack
24+
[With custom datacenter / rack](../../packages/modules/cassandra/src/cassandra-container.test.ts) inside_block:customDataCenterAndRack
2525
<!--/codeinclude-->
2626

2727
<!--codeinclude-->

packages/modules/cassandra/src/cassandra-container.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { CassandraContainer } from "./cassandra-container";
55

66
const IMAGE = getImage(__dirname);
77

8-
describe("Cassandra", { timeout: 240_000 }, () => {
8+
describe.sequential("Cassandra", { timeout: 240_000 }, () => {
99
// connectWithDefaultCredentials {
1010
it("should connect and execute a query with default credentials", async () => {
1111
const container = await new CassandraContainer(IMAGE).start();
@@ -50,7 +50,7 @@ describe("Cassandra", { timeout: 240_000 }, () => {
5050
});
5151
// }
5252

53-
// customDataSenterAndRack {
53+
// customDataCenterAndRack {
5454
it("should set datacenter and rack", async () => {
5555
const customDataCenter = "customDC";
5656
const customRack = "customRack";

packages/modules/gcloud/src/cloudstorage-emulator-container.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function getRequestBodyFromReadableStream(stream: ReadableStream<Uint8Arra
3030
return fullString;
3131
}
3232

33-
describe("CloudStorageEmulatorContainer", { timeout: 240_000 }, () => {
33+
describe.sequential("CloudStorageEmulatorContainer", { timeout: 240_000 }, () => {
3434
const server = setupServer();
3535

3636
beforeAll(() => {

packages/modules/gcloud/src/firestore-emulator-container.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import admin from "firebase-admin";
2+
import { randomUuid } from "testcontainers";
23
import { getImage } from "../../../testcontainers/src/utils/test-helper";
34
import { FirestoreEmulatorContainer, StartedFirestoreEmulatorContainer } from "./firestore-emulator-container";
45

56
const IMAGE = getImage(__dirname);
67

78
describe("FirestoreEmulatorContainer", { timeout: 240_000 }, () => {
8-
afterEach(async () => {
9-
await admin.app().delete();
10-
});
11-
129
// firestore4 {
1310
it("should work using default version", async () => {
1411
const firestoreEmulatorContainer = await new FirestoreEmulatorContainer(IMAGE).start();
@@ -35,10 +32,11 @@ describe("FirestoreEmulatorContainer", { timeout: 240_000 }, () => {
3532
async function checkFirestore(firestoreEmulatorContainer: StartedFirestoreEmulatorContainer) {
3633
expect(firestoreEmulatorContainer).toBeDefined();
3734
const testProjectId = "test-project";
35+
const testAppName = `test-app-${randomUuid()}`;
3836
const testCollection = "test-collection";
3937
const testDocument = "test-doc";
4038
const firebaseConfig = { projectId: testProjectId };
41-
const firestore = admin.initializeApp(firebaseConfig).firestore();
39+
const firestore = admin.initializeApp(firebaseConfig, testAppName).firestore();
4240
firestore.settings({ host: firestoreEmulatorContainer.getEmulatorEndpoint(), ssl: false });
4341

4442
const docRef = firestore.collection(testCollection).doc(testDocument);

packages/modules/kurrentdb/src/kurrentdb-container.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { KurrentDbContainer } from "./kurrentdb-container";
44

55
const IMAGE = getImage(__dirname);
66

7-
describe("KurrentDbContainer", { timeout: 240_000 }, () => {
7+
describe.sequential("KurrentDbContainer", { timeout: 240_000 }, () => {
88
// startContainer {
99
it("should execute write and read", async () => {
1010
const container = await new KurrentDbContainer(IMAGE).start();
@@ -42,6 +42,7 @@ describe("KurrentDbContainer", { timeout: 240_000 }, () => {
4242
]);
4343

4444
await container.stop();
45+
await client.dispose();
4546
});
4647
// }
4748

@@ -86,6 +87,7 @@ describe("KurrentDbContainer", { timeout: 240_000 }, () => {
8687
);
8788
await stream.unsubscribe();
8889
await container.stop();
90+
await client.dispose();
8991
});
9092
// }
9193
});

packages/testcontainers/src/common/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export { IntervalRetry, Retry } from "./retry";
55
export { streamToString } from "./streams";
66
export * from "./time";
77
export * from "./type-guards";
8-
export { RandomUuid, Uuid } from "./uuid";
8+
export { RandomUuid, Uuid, randomUuid } from "./uuid";

packages/testcontainers/src/container-runtime/auth/cred-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class CredHelpers extends CredentialProvider {
77
}
88

99
public getCredentialProviderName(registry: string, dockerConfig: ContainerRuntimeConfig): string | undefined {
10-
if (dockerConfig.credHelpers !== undefined && dockerConfig.credHelpers[registry] !== undefined) {
10+
if (dockerConfig.credHelpers?.[registry] !== undefined) {
1111
return dockerConfig.credHelpers[registry];
1212
}
1313
}

packages/testcontainers/src/container-runtime/auth/credential-provider.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ vi.mock("child_process", () => ({
1111
spawn: (...args: unknown[]) => mockSpawn(...args),
1212
}));
1313

14-
describe("CredentialProvider", () => {
14+
describe.sequential("CredentialProvider", () => {
1515
let credentialProvider: CredentialProvider;
1616
let containerRuntimeConfig: ContainerRuntimeConfig;
1717

packages/testcontainers/src/container-runtime/auth/get-auth-config.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Mock } from "vitest";
1+
import type { Mock } from "vitest";
22

3-
describe("get auth config", () => {
3+
describe.sequential("get auth config", () => {
44
let mockExistsSync: Mock;
55
let mockReadFile: Mock;
66

packages/testcontainers/src/container-runtime/image-name.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ImageName } from "./image-name";
22

3-
describe("ContainerImage", () => {
3+
describe.sequential("ContainerImage", () => {
44
it("should return whether two image names are equal", () => {
55
const imageName = new ImageName("registry", "image", "tag");
66

@@ -10,7 +10,7 @@ describe("ContainerImage", () => {
1010
expect(imageName.equals(new ImageName("anotherRegistry", "image", "tag"))).toBe(false);
1111
});
1212

13-
describe("string", () => {
13+
describe.sequential("string", () => {
1414
it("should work with registry", () => {
1515
const imageName = new ImageName("registry", "image", "tag");
1616
expect(imageName.string).toBe("registry/image:tag");
@@ -67,7 +67,7 @@ describe("ContainerImage", () => {
6767
);
6868
});
6969

70-
describe("fromString", () => {
70+
describe.sequential("fromString", () => {
7171
it("should work", () => {
7272
const imageName = ImageName.fromString("image:latest");
7373

@@ -154,7 +154,7 @@ describe("ContainerImage", () => {
154154
});
155155
});
156156

157-
describe.each([
157+
describe.sequential.each([
158158
{ customRegistry: "custom.com/registry", expectedRegistry: "custom.com", expectedImagePrefix: "registry/" },
159159
{ customRegistry: "custom.com/registry/", expectedRegistry: "custom.com", expectedImagePrefix: "registry/" },
160160
{ customRegistry: "custom.com", expectedRegistry: "custom.com", expectedImagePrefix: "" },

0 commit comments

Comments
 (0)