Remove jest-testcontainers.
This commit is contained in:
parent
6bd6ee779b
commit
66cfb8eedd
|
@ -10,7 +10,7 @@ module.exports = () => {
|
|||
wait: {
|
||||
type: "ports",
|
||||
timeout: 20000,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class Replication {
|
|||
return resolve(info)
|
||||
})
|
||||
.on("error", function (err) {
|
||||
throw new Error(`Replication Error: ${err}`)
|
||||
throw err
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
const { join } = require("path")
|
||||
require("dotenv").config({
|
||||
path: join(__dirname, "..", "..", "hosting", ".env"),
|
||||
})
|
||||
|
||||
const jestTestcontainersConfigGenerator = require("../../jestTestcontainersConfigGenerator")
|
||||
|
||||
module.exports = jestTestcontainersConfigGenerator()
|
|
@ -18,6 +18,8 @@ const baseConfig: Config.InitialProjectOptions = {
|
|||
"svelte",
|
||||
],
|
||||
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],
|
||||
globalSetup: "./src/tests/globalSetup.ts",
|
||||
globalTeardown: "./src/tests/globalTeardown.ts",
|
||||
transform: {
|
||||
"^.+\\.ts?$": "@swc/jest",
|
||||
"^.+\\.js?$": "@swc/jest",
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
import { GenericContainer, Wait } from "testcontainers"
|
||||
|
||||
export default async function setup() {
|
||||
const container = await new GenericContainer("budibase/couchdb")
|
||||
.withName("couchdb-service")
|
||||
.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()
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
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)
|
||||
}
|
|
@ -11,3 +11,6 @@ process.env.PLATFORM_URL = "http://localhost:10000"
|
|||
process.env.REDIS_PASSWORD = "budibase"
|
||||
process.env.BUDIBASE_VERSION = "0.0.0+jest"
|
||||
process.env.WORKER_URL = "http://localhost:10000"
|
||||
process.env.COUCH_DB_PASSWORD = "budibase"
|
||||
process.env.COUCH_DB_USER = "budibase"
|
||||
process.env.JWT_SECRET = "jwtsecret"
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
[log]
|
||||
level = warn
|
|
@ -187,6 +187,22 @@ export abstract class TestAPI {
|
|||
expect(response.body).toMatchObject(expectations.body)
|
||||
}
|
||||
|
||||
if (response.text && response.text.length > 0) {
|
||||
// @ts-expect-error - we know this exists, it's just not in the types
|
||||
const request = response.request as Test
|
||||
const contentLength = response.headers["content-length"]
|
||||
if (!contentLength) {
|
||||
throw new Error(
|
||||
`Failed request "${request.method} ${request.url}": Content-Length header not present, but response has a body (body length ${response.text.length})`
|
||||
)
|
||||
}
|
||||
if (parseInt(contentLength) !== response.text.length) {
|
||||
throw new Error(
|
||||
`Failed request "${request.method} ${request.url}": Content-Length header does not match response body length (header: ${contentLength}, body: ${response.text.length})`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue