budibase/packages/server/jest.config.ts

55 lines
1.5 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"
2023-05-22 14:33:38 +02:00
import { join } from "path"
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",
},
moduleNameMapper: {
2023-02-01 12:02:29 +01:00
"@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
"@budibase/backend-core": "<rootDir>/../backend-core/src",
"@budibase/shared-core": "<rootDir>/../shared-core/src",
2023-02-01 12:02:29 +01:00
"@budibase/types": "<rootDir>/../types/src",
},
}
2023-04-14 18:18:15 +02:00
// add pro sources if they exist
if (fs.existsSync("../pro/src")) {
2023-06-20 14:42:39 +02:00
baseConfig.moduleNameMapper!["@budibase/pro"] = "<rootDir>/../pro/src"
2023-04-14 18:18:15 +02: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}",
"../backend-core/src/**/*.{js,ts}",
// The use of coverage with couchdb view functions breaks tests
"!src/db/views/staticViews.*",
"!src/**/*.spec.{js,ts}",
"!src/tests/**/*.{js,ts}",
],
coverageReporters: ["lcov", "json", "clover"],
2023-01-26 12:38:21 +01:00
}
2023-05-22 14:33:38 +02:00
process.env.TOP_LEVEL_PATH = join(__dirname, "..", "..")
export default config