-
Notifications
You must be signed in to change notification settings - Fork 3
/
jest.config.js
51 lines (47 loc) · 1.75 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//const config = require('@polkadot/dev/config/jest.cjs');
// Copyright 2017-2022 @polkadot/dev authors & contributors
// SPDX-License-Identifier: Apache-2.0
const fs = require("fs");
const { defaults } = require("jest-config");
module.exports = {
moduleFileExtensions: [...defaults.moduleFileExtensions, "ts", "tsx"],
modulePathIgnorePatterns: [
"<rootDir>/build",
"<rootDir>/build-tsc-cjs",
"<rootDir>/build-tsc-ems",
"<rootDir>/build-tsc-js",
].concat(
fs
.readdirSync("packages")
.filter((p) => fs.statSync(`packages/${p}`).isDirectory())
.map((p) => `<rootDir>/packages/${p}/build`)
),
// See https://jestjs.io/docs/configuration#extraglobals-arraystring
sandboxInjectedGlobals: ["Math"],
testMatch: [
"**/__tests__/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[jt]s?(x)",
],
preset: "ts-jest",
testEnvironment: "node",
transform: {
"node_modules/variables/.+\\.(j|t)sx?$": [
"ts-jest",
{ tsconfig: "./tsconfig.jest.json", useESM: true },
],
"\\.[jt]sx?$": [
"ts-jest",
{ tsconfig: "./tsconfig.jest.json", useESM: true },
],
".ts": ["ts-jest", { tsconfig: "./tsconfig.jest.json", useESM: true }],
},
transformIgnorePatterns: ["node_modules/(?!variables/.*)"],
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"@encointer/node-api(.*)$": "<rootDir>/packages/node-api/src/$1",
"@encointer/worker-api(.*)$": "<rootDir>/packages/worker-api/src/$1",
"@encointer/util(.*)$": "<rootDir>/packages/util/src/$1",
"@encointer/types(.*)$": "<rootDir>/packages/types/src/$1",
},
resolver: "jest-ts-webcompat-resolver",
};