budibase/packages/server/jest.config.ts

70 lines
1.9 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"
2023-02-03 20:08:45 +01:00
const baseConfig: Config.InitialProjectOptions = {
preset: "@trendyol/jest-testcontainers",
setupFiles: ["./src/tests/jestEnv.ts"],
moduleFileExtensions: [
"js",
"mjs",
"cjs",
"jsx",
"ts",
"tsx",
"json",
"node",
"svelte",
],
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],
2023-02-01 12:02:29 +01:00
transform: {
"^.+\\.ts?$": "@swc/jest",
"^.+\\.js?$": "@swc/jest",
"^.+\\.svelte?$": "<rootDir>/scripts/svelteTransformer.js",
2023-02-01 12:02:29 +01:00
},
transformIgnorePatterns: ["/node_modules/(?!svelte/).*"],
moduleNameMapper: {
2023-02-01 12:02:29 +01:00
"@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
"@budibase/shared-core/(.*)": "<rootDir>/../shared-core/$1",
2023-02-01 12:02:29 +01:00
"@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",
2024-03-15 16:40:30 +01:00
"@budibase/string-templates/(.*)": ["<rootDir>/../string-templates/$1"],
2024-03-15 14:53:25 +01:00
"@budibase/string-templates": ["<rootDir>/../string-templates/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