forked from codeoverflow-org/nodecg-io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.mjs
31 lines (26 loc) · 889 Bytes
/
jest.config.mjs
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
import path from "path";
import { readdirSync } from "fs";
import { cwd } from "process";
import { getPackages } from "@manypkg/get-packages";
let projects = [];
// @ts-ignore
const { packages } = await getPackages(cwd());
/** @param pkg {import("@manypkg/get-packages").Package} */
function hasJestConfig(pkg) {
return (
readdirSync(pkg.dir).some(
(file) =>
file === "jest.config.js" ||
file === "jest.config.ts" ||
file === "jest.config.cjs" ||
file === "jest.config.mjs" ||
file === "jest.config.json",
) || pkg.packageJson["jest"]
);
}
projects = packages.filter((pkg) => hasJestConfig(pkg)).map((v) => `<rootDir>/${path.relative(cwd(), v.dir)}`);
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
projects,
};
export default config;