2023-01-26 15:18:56 +01:00
|
|
|
import { Config } from "jest"
|
2023-02-01 11:57:05 +01:00
|
|
|
|
2022-11-14 14:29:46 +01:00
|
|
|
import * as fs from "fs"
|
2022-12-15 22:06:30 +01:00
|
|
|
const preset = require("ts-jest/jest-preset")
|
2022-11-14 14:29:46 +01:00
|
|
|
|
2023-02-01 11:57:05 +01:00
|
|
|
const testContainersSettings = {
|
2022-12-15 22:06:30 +01:00
|
|
|
...preset,
|
|
|
|
preset: "@trendyol/jest-testcontainers",
|
2023-01-11 10:37:37 +01:00
|
|
|
setupFiles: ["./src/tests/jestEnv.ts"],
|
|
|
|
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],
|
2023-02-01 11:57:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const config: Config = {
|
|
|
|
projects: [
|
|
|
|
{
|
|
|
|
...testContainersSettings,
|
|
|
|
displayName: "sequential test",
|
|
|
|
testMatch: ["<rootDir>/**/*.seq.spec.[jt]s"],
|
|
|
|
runner: "jest-serial-runner",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
...testContainersSettings,
|
|
|
|
testMatch: ["<rootDir>/**/!(*.seq).spec.[jt]s"],
|
|
|
|
},
|
|
|
|
],
|
2022-11-14 14:29:46 +01:00
|
|
|
collectCoverageFrom: [
|
|
|
|
"src/**/*.{js,ts}",
|
|
|
|
// The use of coverage with couchdb view functions breaks tests
|
|
|
|
"!src/db/views/staticViews.*",
|
|
|
|
],
|
|
|
|
coverageReporters: ["lcov", "json", "clover"],
|
2023-01-11 10:37:37 +01:00
|
|
|
transform: {
|
|
|
|
"^.+\\.ts?$": "@swc/jest",
|
|
|
|
},
|
2022-11-14 14:29:46 +01:00
|
|
|
}
|
|
|
|
|
2023-01-26 12:38:21 +01:00
|
|
|
if (!process.env.CI) {
|
|
|
|
// use sources when not in CI
|
2023-02-01 11:57:05 +01:00
|
|
|
config.moduleNameMapper = {
|
2023-01-26 12:38:21 +01:00
|
|
|
"@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
|
|
|
|
"@budibase/backend-core": "<rootDir>/../backend-core/src",
|
|
|
|
"@budibase/types": "<rootDir>/../types/src",
|
|
|
|
}
|
|
|
|
// add pro sources if they exist
|
|
|
|
if (fs.existsSync("../../../budibase-pro")) {
|
2023-02-01 11:57:05 +01:00
|
|
|
config.moduleNameMapper["@budibase/pro"] =
|
2023-01-26 12:38:21 +01:00
|
|
|
"<rootDir>/../../../budibase-pro/packages/pro/src"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
console.log("Running tests with compiled dependency sources")
|
|
|
|
}
|
|
|
|
|
2022-11-14 14:29:46 +01:00
|
|
|
export default config
|