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 = {
|
2023-01-11 22:37:37 +13:00
|
|
|
setupFiles: ["./src/tests/jestEnv.ts"],
|
2024-02-23 02:19:29 +13:00
|
|
|
moduleFileExtensions: [
|
|
|
|
"js",
|
|
|
|
"mjs",
|
|
|
|
"cjs",
|
|
|
|
"jsx",
|
|
|
|
"ts",
|
|
|
|
"tsx",
|
|
|
|
"json",
|
|
|
|
"node",
|
|
|
|
"svelte",
|
|
|
|
],
|
2023-01-11 22:37:37 +13:00
|
|
|
setupFilesAfterEnv: ["./src/tests/jestSetup.ts"],
|
2024-03-23 06:04:45 +13:00
|
|
|
globalSetup: "./src/tests/globalSetup.ts",
|
|
|
|
globalTeardown: "./src/tests/globalTeardown.ts",
|
2023-02-02 00:02:29 +13:00
|
|
|
transform: {
|
|
|
|
"^.+\\.ts?$": "@swc/jest",
|
2024-02-23 02:19:29 +13:00
|
|
|
"^.+\\.js?$": "@swc/jest",
|
|
|
|
"^.+\\.svelte?$": "<rootDir>/scripts/svelteTransformer.js",
|
2023-02-02 00:02:29 +13:00
|
|
|
},
|
2024-02-23 02:19:29 +13:00
|
|
|
transformIgnorePatterns: ["/node_modules/(?!svelte/).*"],
|
2023-02-22 06:13:24 +13:00
|
|
|
moduleNameMapper: {
|
2023-02-02 00:02:29 +13:00
|
|
|
"@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
|
2023-08-18 00:31:52 +12:00
|
|
|
"@budibase/shared-core/(.*)": "<rootDir>/../shared-core/$1",
|
2023-02-02 00:02:29 +13:00
|
|
|
"@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",
|
2024-03-16 04:40:30 +13:00
|
|
|
"@budibase/string-templates/(.*)": ["<rootDir>/../string-templates/$1"],
|
2024-03-16 02:53:25 +13:00
|
|
|
"@budibase/string-templates": ["<rootDir>/../string-templates/src"],
|
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
|