Don't need a globalTeardown, testcontainers handles the removal of containers.
This commit is contained in:
parent
e5c7e653e4
commit
415b27a008
|
@ -1,7 +1,7 @@
|
||||||
import { GenericContainer, Wait } from "testcontainers"
|
import { GenericContainer, Wait } from "testcontainers"
|
||||||
|
|
||||||
export default async function setup() {
|
export default async function setup() {
|
||||||
const container = await new GenericContainer("budibase/couchdb")
|
await new GenericContainer("budibase/couchdb")
|
||||||
.withExposedPorts(5984)
|
.withExposedPorts(5984)
|
||||||
.withEnvironment({
|
.withEnvironment({
|
||||||
COUCHDB_PASSWORD: "budibase",
|
COUCHDB_PASSWORD: "budibase",
|
||||||
|
@ -22,8 +22,4 @@ export default async function setup() {
|
||||||
).withStartupTimeout(20000)
|
).withStartupTimeout(20000)
|
||||||
)
|
)
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
globalThis.__COUCHDB_CONTAINER_ID__ = container.getId()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
|
||||||
}
|
|
|
@ -3,7 +3,6 @@ import { Config } from "@jest/types"
|
||||||
const baseConfig: Config.InitialProjectOptions = {
|
const baseConfig: Config.InitialProjectOptions = {
|
||||||
setupFiles: ["./tests/jestEnv.ts"],
|
setupFiles: ["./tests/jestEnv.ts"],
|
||||||
globalSetup: "./../../globalSetup.ts",
|
globalSetup: "./../../globalSetup.ts",
|
||||||
globalTeardown: "./../../globalTeardown.ts",
|
|
||||||
setupFilesAfterEnv: ["./tests/jestSetup.ts"],
|
setupFilesAfterEnv: ["./tests/jestSetup.ts"],
|
||||||
transform: {
|
transform: {
|
||||||
"^.+\\.ts?$": "@swc/jest",
|
"^.+\\.ts?$": "@swc/jest",
|
||||||
|
|
|
@ -18,7 +18,6 @@ const baseConfig: Config.InitialProjectOptions = {
|
||||||
],
|
],
|
||||||
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],
|
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],
|
||||||
globalSetup: "./../../globalSetup.ts",
|
globalSetup: "./../../globalSetup.ts",
|
||||||
globalTeardown: "./../../globalTeardown.ts",
|
|
||||||
transform: {
|
transform: {
|
||||||
"^.+\\.ts?$": "@swc/jest",
|
"^.+\\.ts?$": "@swc/jest",
|
||||||
"^.+\\.js?$": "@swc/jest",
|
"^.+\\.js?$": "@swc/jest",
|
||||||
|
|
|
@ -3,7 +3,6 @@ import * as fs from "fs"
|
||||||
|
|
||||||
const config: Config.InitialOptions = {
|
const config: Config.InitialOptions = {
|
||||||
globalSetup: "./../../globalSetup.ts",
|
globalSetup: "./../../globalSetup.ts",
|
||||||
globalTeardown: "./../../globalTeardown.ts",
|
|
||||||
setupFiles: ["./src/tests/jestEnv.ts"],
|
setupFiles: ["./src/tests/jestEnv.ts"],
|
||||||
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],
|
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],
|
||||||
collectCoverageFrom: ["src/**/*.{js,ts}", "../backend-core/src/**/*.{js,ts}"],
|
collectCoverageFrom: ["src/**/*.{js,ts}", "../backend-core/src/**/*.{js,ts}"],
|
||||||
|
|
Loading…
Reference in New Issue