Don't need a globalTeardown, testcontainers handles the removal of containers.

This commit is contained in:
Sam Rose 2024-03-26 10:00:34 +00:00
parent e5c7e653e4
commit 415b27a008
No known key found for this signature in database
5 changed files with 1 additions and 20 deletions

View File

@ -1,7 +1,7 @@
import { GenericContainer, Wait } from "testcontainers"
export default async function setup() {
const container = await new GenericContainer("budibase/couchdb")
await new GenericContainer("budibase/couchdb")
.withExposedPorts(5984)
.withEnvironment({
COUCHDB_PASSWORD: "budibase",
@ -22,8 +22,4 @@ export default async function setup() {
).withStartupTimeout(20000)
)
.start()
// @ts-ignore
// eslint-disable-next-line no-undef
globalThis.__COUCHDB_CONTAINER_ID__ = container.getId()
}

View File

@ -1,12 +0,0 @@
import { getContainerRuntimeClient } from "testcontainers"
export default async function teardown() {
const client = await getContainerRuntimeClient()
// @ts-expect-error
// eslint-disable-next-line no-undef
const containerId = globalThis.__COUCHDB_CONTAINER_ID__
const container = client.container.getById(containerId)
await client.container.stop(container)
await client.container.remove(container)
}

View File

@ -3,7 +3,6 @@ import { Config } from "@jest/types"
const baseConfig: Config.InitialProjectOptions = {
setupFiles: ["./tests/jestEnv.ts"],
globalSetup: "./../../globalSetup.ts",
globalTeardown: "./../../globalTeardown.ts",
setupFilesAfterEnv: ["./tests/jestSetup.ts"],
transform: {
"^.+\\.ts?$": "@swc/jest",

View File

@ -18,7 +18,6 @@ const baseConfig: Config.InitialProjectOptions = {
],
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],
globalSetup: "./../../globalSetup.ts",
globalTeardown: "./../../globalTeardown.ts",
transform: {
"^.+\\.ts?$": "@swc/jest",
"^.+\\.js?$": "@swc/jest",

View File

@ -3,7 +3,6 @@ import * as fs from "fs"
const config: Config.InitialOptions = {
globalSetup: "./../../globalSetup.ts",
globalTeardown: "./../../globalTeardown.ts",
setupFiles: ["./src/tests/jestEnv.ts"],
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],
collectCoverageFrom: ["src/**/*.{js,ts}", "../backend-core/src/**/*.{js,ts}"],