2023-02-03 20:07:41 +01:00
|
|
|
import { Config } from "@jest/types"
|
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-03 20:08:45 +01:00
|
|
|
const baseConfig: Config.InitialProjectOptions = {
|
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 12:02:29 +01:00
|
|
|
transform: {
|
|
|
|
"^.+\\.ts?$": "@swc/jest",
|
|
|
|
},
|
2023-02-21 18:13:24 +01:00
|
|
|
moduleNameMapper: {
|
2023-02-01 12:02:29 +01:00
|
|
|
"@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
|
|
|
|
"@budibase/backend-core": "<rootDir>/../backend-core/src",
|
2023-03-09 09:50:26 +01:00
|
|
|
"@budibase/shared-core": "<rootDir>/../shared-core/src",
|
2023-02-01 12:02:29 +01:00
|
|
|
"@budibase/types": "<rootDir>/../types/src",
|
2023-02-21 18:13:24 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2023-04-14 18:18:15 +02:00
|
|
|
// add pro sources if they exist
|
|
|
|
if (fs.existsSync("../pro/packages")) {
|
|
|
|
baseConfig.moduleNameMapper!["@budibase/pro"] =
|
|
|
|
"<rootDir>/../pro/packages/pro/src"
|
|
|
|
}
|
|
|
|
|
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"],
|
|
|
|
},
|
|
|
|
],
|
2022-11-14 14:29:46 +01:00
|
|
|
collectCoverageFrom: [
|
|
|
|
"src/**/*.{js,ts}",
|
2023-02-27 18:07:52 +01:00
|
|
|
"../backend-core/src/**/*.{js,ts}",
|
2022-11-14 14:29:46 +01:00
|
|
|
// The use of coverage with couchdb view functions breaks tests
|
|
|
|
"!src/db/views/staticViews.*",
|
2023-03-28 01:10:46 +02:00
|
|
|
"!src/**/*.spec.{js,ts}",
|
2023-03-31 11:32:13 +02:00
|
|
|
"!src/tests/**/*.{js,ts}",
|
2022-11-14 14:29:46 +01:00
|
|
|
],
|
|
|
|
coverageReporters: ["lcov", "json", "clover"],
|
2023-01-26 12:38:21 +01:00
|
|
|
}
|
|
|
|
|
2022-11-14 14:29:46 +01:00
|
|
|
export default config
|