budibase/packages/server/jest.config.ts

54 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-02-03 20:07:41 +01:00
import { Config } from "@jest/types"
2023-02-01 11:57:05 +01:00
import * as fs from "fs"
const preset = require("ts-jest/jest-preset")
2023-02-03 20:08:45 +01:00
const baseConfig: Config.InitialProjectOptions = {
...preset,
preset: "@trendyol/jest-testcontainers",
setupFiles: ["./src/tests/jestEnv.ts"],
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],
2023-02-01 12:02:29 +01:00
transform: {
"^.+\\.ts?$": "@swc/jest",
},
}
if (!process.env.CI) {
// use sources when not in CI
2023-02-03 20:08:45 +01:00
baseConfig.moduleNameMapper = {
2023-02-01 12:02:29 +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-03 20:08:45 +01:00
baseConfig.moduleNameMapper["@budibase/pro"] =
2023-02-01 12:02:29 +01:00
"<rootDir>/../../../budibase-pro/packages/pro/src"
}
} else {
console.log("Running tests with compiled dependency sources")
2023-02-01 11:57:05 +01:00
}
2023-02-03 20:07:41 +01:00
const config: Config.InitialOptions = {
2023-02-01 11:57:05 +01:00
projects: [
{
2023-02-03 20:08:45 +01:00
...baseConfig,
2023-02-01 11:57:05 +01:00
displayName: "sequential test",
testMatch: ["<rootDir>/**/*.seq.spec.[jt]s"],
runner: "jest-serial-runner",
},
{
2023-02-03 20:08:45 +01:00
...baseConfig,
2023-02-01 11:57:05 +01:00
testMatch: ["<rootDir>/**/!(*.seq).spec.[jt]s"],
},
],
collectCoverageFrom: [
"src/**/*.{js,ts}",
// The use of coverage with couchdb view functions breaks tests
"!src/db/views/staticViews.*",
],
coverageReporters: ["lcov", "json", "clover"],
2023-01-26 12:38:21 +01:00
}
export default config