2023-02-04 08:07:41 +13:00
|
|
|
import { Config } from "@jest/types"
|
2023-02-01 23:57:05 +13:00
|
|
|
|
2022-11-15 02:29:46 +13:00
|
|
|
import * as fs from "fs"
|
2023-05-23 00:33:38 +12:00
|
|
|
import { join } from "path"
|
2022-11-15 02:29:46 +13:00
|
|
|
|
2023-02-04 08:08:45 +13:00
|
|
|
const baseConfig: Config.InitialProjectOptions = {
|
2022-12-16 10:06:30 +13:00
|
|
|
preset: "@trendyol/jest-testcontainers",
|
2023-01-11 22:37:37 +13:00
|
|
|
setupFiles: ["./src/tests/jestEnv.ts"],
|
|
|
|
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],
|
2023-02-02 00:02:29 +13:00
|
|
|
transform: {
|
|
|
|
"^.+\\.ts?$": "@swc/jest",
|
|
|
|
},
|
2023-02-22 06:13:24 +13:00
|
|
|
moduleNameMapper: {
|
2023-02-02 00:02:29 +13:00
|
|
|
"@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
|
|
|
|
"@budibase/backend-core": "<rootDir>/../backend-core/src",
|
2023-03-09 21:50:26 +13:00
|
|
|
"@budibase/shared-core": "<rootDir>/../shared-core/src",
|
2023-02-02 00:02:29 +13:00
|
|
|
"@budibase/types": "<rootDir>/../types/src",
|
2023-02-22 06:13:24 +13:00
|
|
|
},
|
2023-07-28 02:04:19 +12:00
|
|
|
workerIdleMemoryLimit: "50%",
|
2023-02-22 06:13:24 +13:00
|
|
|
}
|
|
|
|
|
2023-04-15 04:18:15 +12:00
|
|
|
// add pro sources if they exist
|
2023-06-20 05:34:51 +12:00
|
|
|
if (fs.existsSync("../pro/src")) {
|
2023-06-21 00:42:39 +12:00
|
|
|
baseConfig.moduleNameMapper!["@budibase/pro"] = "<rootDir>/../pro/src"
|
2023-04-15 04:18:15 +12:00
|
|
|
}
|
|
|
|
|
2023-02-04 08:07:41 +13:00
|
|
|
const config: Config.InitialOptions = {
|
2023-02-01 23:57:05 +13:00
|
|
|
projects: [
|
|
|
|
{
|
2023-02-04 08:08:45 +13:00
|
|
|
...baseConfig,
|
2023-02-01 23:57:05 +13:00
|
|
|
displayName: "sequential test",
|
|
|
|
testMatch: ["<rootDir>/**/*.seq.spec.[jt]s"],
|
|
|
|
runner: "jest-serial-runner",
|
|
|
|
},
|
|
|
|
{
|
2023-02-04 08:08:45 +13:00
|
|
|
...baseConfig,
|
2023-02-01 23:57:05 +13:00
|
|
|
testMatch: ["<rootDir>/**/!(*.seq).spec.[jt]s"],
|
|
|
|
},
|
|
|
|
],
|
2022-11-15 02:29:46 +13:00
|
|
|
collectCoverageFrom: [
|
|
|
|
"src/**/*.{js,ts}",
|
2023-02-28 06:07:52 +13:00
|
|
|
"../backend-core/src/**/*.{js,ts}",
|
2022-11-15 02:29:46 +13:00
|
|
|
// The use of coverage with couchdb view functions breaks tests
|
|
|
|
"!src/db/views/staticViews.*",
|
2023-03-28 12:10:46 +13:00
|
|
|
"!src/**/*.spec.{js,ts}",
|
2023-03-31 22:32:13 +13:00
|
|
|
"!src/tests/**/*.{js,ts}",
|
2022-11-15 02:29:46 +13:00
|
|
|
],
|
|
|
|
coverageReporters: ["lcov", "json", "clover"],
|
2023-01-27 00:38:21 +13:00
|
|
|
}
|
|
|
|
|
2023-05-23 00:33:38 +12:00
|
|
|
process.env.TOP_LEVEL_PATH = join(__dirname, "..", "..")
|
|
|
|
|
2022-11-15 02:29:46 +13:00
|
|
|
export default config
|