import { Config } from "jest" import * as fs from "fs" const preset = require("ts-jest/jest-preset") const configSettings = { ...preset, preset: "@trendyol/jest-testcontainers", setupFiles: ["./src/tests/jestEnv.ts"], setupFilesAfterEnv: ["./src/tests/jestSetup.ts"], collectCoverageFrom: [ "src/**/*.{js,ts}", // The use of coverage with couchdb view functions breaks tests "!src/db/views/staticViews.*", ], coverageReporters: ["lcov", "json", "clover"], transform: { "^.+\\.ts?$": "@swc/jest", }, } if (!process.env.CI) { // use sources when not in CI configSettings.moduleNameMapper = { "@budibase/backend-core/(.*)": "/../backend-core/$1", "@budibase/backend-core": "/../backend-core/src", "@budibase/types": "/../types/src", } // add pro sources if they exist if (fs.existsSync("../../../budibase-pro")) { configSettings.moduleNameMapper["@budibase/pro"] = "/../../../budibase-pro/packages/pro/src" } } else { console.log("Running tests with compiled dependency sources") } const config: Config = { projects: [ { ...configSettings, displayName: "sequential test", testMatch: ["/**/*.seq.spec.[jt]s"], runner: "jest-serial-runner", }, { ...configSettings, testMatch: ["/**/!(*.seq).spec.[jt]s"], }, ], } export default config