diff --git a/packages/backend-core/src/tests/globalSetup.ts b/globalSetup.ts similarity index 90% rename from packages/backend-core/src/tests/globalSetup.ts rename to globalSetup.ts index fd9cd8e020..f110bd5cd4 100644 --- a/packages/backend-core/src/tests/globalSetup.ts +++ b/globalSetup.ts @@ -9,7 +9,7 @@ export default async function setup() { }) .withCopyFilesToContainer([ { - source: "./src/tests/test-couchdb.ini", + source: "./test-couchdb.ini", target: "/opt/couchdb/etc/local.d/test-couchdb.ini", }, ]) @@ -20,7 +20,6 @@ export default async function setup() { ) .start() - // @ts-expect-error // eslint-disable-next-line no-undef globalThis.__COUCHDB_CONTAINER_ID__ = container.getId() } diff --git a/packages/backend-core/src/tests/globalTeardown.ts b/globalTeardown.ts similarity index 100% rename from packages/backend-core/src/tests/globalTeardown.ts rename to globalTeardown.ts diff --git a/packages/server/jest.config.ts b/packages/server/jest.config.ts index 5795bedca5..bad03f045c 100644 --- a/packages/server/jest.config.ts +++ b/packages/server/jest.config.ts @@ -17,8 +17,8 @@ const baseConfig: Config.InitialProjectOptions = { "svelte", ], setupFilesAfterEnv: ["./src/tests/jestSetup.ts"], - globalSetup: "./src/tests/globalSetup.ts", - globalTeardown: "./src/tests/globalTeardown.ts", + globalSetup: "./../../globalSetup.ts", + globalTeardown: "./../../globalTeardown.ts", transform: { "^.+\\.ts?$": "@swc/jest", "^.+\\.js?$": "@swc/jest", diff --git a/packages/server/scripts/test.sh b/packages/server/scripts/test.sh index 3ecf8bb794..c9f063c409 100644 --- a/packages/server/scripts/test.sh +++ b/packages/server/scripts/test.sh @@ -1,6 +1,8 @@ #!/bin/bash set -e +export DEBUG=testcontainers* + if [[ -n $CI ]] then export NODE_OPTIONS="--max-old-space-size=4096 --no-node-snapshot $NODE_OPTIONS" diff --git a/packages/server/src/tests/globalSetup.ts b/packages/server/src/tests/globalSetup.ts deleted file mode 100644 index fd9cd8e020..0000000000 --- a/packages/server/src/tests/globalSetup.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { GenericContainer, Wait } from "testcontainers" - -export default async function setup() { - const container = await new GenericContainer("budibase/couchdb") - .withExposedPorts(5984) - .withEnvironment({ - COUCHDB_PASSWORD: "budibase", - COUCHDB_USER: "budibase", - }) - .withCopyFilesToContainer([ - { - source: "./src/tests/test-couchdb.ini", - target: "/opt/couchdb/etc/local.d/test-couchdb.ini", - }, - ]) - .withWaitStrategy( - Wait.forSuccessfulCommand( - "curl http://budibase:budibase@localhost:5984/_up" - ).withStartupTimeout(20000) - ) - .start() - - // @ts-expect-error - // eslint-disable-next-line no-undef - globalThis.__COUCHDB_CONTAINER_ID__ = container.getId() -} diff --git a/packages/server/src/tests/globalTeardown.ts b/packages/server/src/tests/globalTeardown.ts deleted file mode 100644 index 4be959c1f9..0000000000 --- a/packages/server/src/tests/globalTeardown.ts +++ /dev/null @@ -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) -} diff --git a/packages/worker/src/tests/globalSetup.ts b/packages/worker/src/tests/globalSetup.ts deleted file mode 100644 index fd9cd8e020..0000000000 --- a/packages/worker/src/tests/globalSetup.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { GenericContainer, Wait } from "testcontainers" - -export default async function setup() { - const container = await new GenericContainer("budibase/couchdb") - .withExposedPorts(5984) - .withEnvironment({ - COUCHDB_PASSWORD: "budibase", - COUCHDB_USER: "budibase", - }) - .withCopyFilesToContainer([ - { - source: "./src/tests/test-couchdb.ini", - target: "/opt/couchdb/etc/local.d/test-couchdb.ini", - }, - ]) - .withWaitStrategy( - Wait.forSuccessfulCommand( - "curl http://budibase:budibase@localhost:5984/_up" - ).withStartupTimeout(20000) - ) - .start() - - // @ts-expect-error - // eslint-disable-next-line no-undef - globalThis.__COUCHDB_CONTAINER_ID__ = container.getId() -} diff --git a/packages/worker/src/tests/globalTeardown.ts b/packages/worker/src/tests/globalTeardown.ts deleted file mode 100644 index 4be959c1f9..0000000000 --- a/packages/worker/src/tests/globalTeardown.ts +++ /dev/null @@ -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) -} diff --git a/packages/server/src/tests/test-couchdb.ini b/test-couchdb.ini similarity index 100% rename from packages/server/src/tests/test-couchdb.ini rename to test-couchdb.ini