-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
31 lines (26 loc) · 1.01 KB
/
jest.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const path = require("path");
const fs = require("fs");
const rootDir = process.cwd().split("packages").shift();
const packagesDir = path.resolve(rootDir, "./packages");
const moduleNameMapper = fs
.readdirSync(packagesDir)
.map(dir => path.resolve(packagesDir, dir))
.filter(f => fs.statSync(f).isDirectory() && fs.existsSync(path.resolve(f, "./package.json")))
.reduce((prev, cur) => {
const pkgName = path.basename(cur);
const pkgjson = JSON.parse(fs.readFileSync(path.resolve(cur, "./package.json")).toString());
prev[`^${pkgjson.name}`] = path.resolve(rootDir, `./packages/${pkgName}/lib/index.ts`);
return prev;
}, {});
const utMdus = (process.env.UT_MDU || "*").split(",");
module.exports = {
rootDir,
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "vue"],
moduleNameMapper,
transform: {
"^.+\\.(ts|tsx)$": "ts-jest"
},
coverageDirectory: path.resolve(rootDir, "./coverage"),
collectCoverage: true,
testMatch: utMdus.map(mdu => `<rootDir>/packages/${mdu}/__tests__/**/*.(test|spec).(ts|js)`)
};