Share a single globalSetup/globalTeardown.
This commit is contained in:
parent
afacee978d
commit
f3e9e3d35e
|
@ -9,7 +9,7 @@ export default async function setup() {
|
||||||
})
|
})
|
||||||
.withCopyFilesToContainer([
|
.withCopyFilesToContainer([
|
||||||
{
|
{
|
||||||
source: "./src/tests/test-couchdb.ini",
|
source: "./test-couchdb.ini",
|
||||||
target: "/opt/couchdb/etc/local.d/test-couchdb.ini",
|
target: "/opt/couchdb/etc/local.d/test-couchdb.ini",
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
@ -20,7 +20,6 @@ export default async function setup() {
|
||||||
)
|
)
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
// @ts-expect-error
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
globalThis.__COUCHDB_CONTAINER_ID__ = container.getId()
|
globalThis.__COUCHDB_CONTAINER_ID__ = container.getId()
|
||||||
}
|
}
|
|
@ -17,8 +17,8 @@ const baseConfig: Config.InitialProjectOptions = {
|
||||||
"svelte",
|
"svelte",
|
||||||
],
|
],
|
||||||
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],
|
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],
|
||||||
globalSetup: "./src/tests/globalSetup.ts",
|
globalSetup: "./../../globalSetup.ts",
|
||||||
globalTeardown: "./src/tests/globalTeardown.ts",
|
globalTeardown: "./../../globalTeardown.ts",
|
||||||
transform: {
|
transform: {
|
||||||
"^.+\\.ts?$": "@swc/jest",
|
"^.+\\.ts?$": "@swc/jest",
|
||||||
"^.+\\.js?$": "@swc/jest",
|
"^.+\\.js?$": "@swc/jest",
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
export DEBUG=testcontainers*
|
||||||
|
|
||||||
if [[ -n $CI ]]
|
if [[ -n $CI ]]
|
||||||
then
|
then
|
||||||
export NODE_OPTIONS="--max-old-space-size=4096 --no-node-snapshot $NODE_OPTIONS"
|
export NODE_OPTIONS="--max-old-space-size=4096 --no-node-snapshot $NODE_OPTIONS"
|
||||||
|
|
|
@ -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()
|
|
||||||
}
|
|
|
@ -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)
|
|
||||||
}
|
|
|
@ -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()
|
|
||||||
}
|
|
|
@ -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)
|
|
||||||
}
|
|
Loading…
Reference in New Issue