-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathjest.config.js
101 lines (95 loc) · 3.04 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { isCI } from '@terascope/utils';
const dirname = path.dirname(fileURLToPath(import.meta.url));
const packagesPath = path.join(dirname, 'packages');
const projects = fs
.readdirSync(packagesPath)
.filter((pkgName) => {
const pkgDir = path.join(packagesPath, pkgName);
if (!fs.statSync(pkgDir).isDirectory()) return false;
const pkgPath = path.join(pkgDir, 'package.json');
const hasPkg = fs.existsSync(pkgPath);
if (hasPkg) {
const { terascope = {} } = JSON.parse(fs.readFileSync(pkgPath));
const { testSuite = 'disabled' } = terascope;
if (testSuite === 'disabled') {
return false;
}
return true;
}
return false;
})
.map((pkgName) => `<rootDir>/packages/${pkgName}`);
const coverageReporters = ['lcov', 'html'];
if (!isCI) {
coverageReporters.push('text-summary');
}
export default {
rootDir: '.',
verbose: true,
testTimeout: 60 * 1000,
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
projects,
globals: {
availableExtensions: ['.js', '.ts', '.mjs', '.cjs'],
},
testMatch: [
'<rootDir>/packages/*/test/**/*-spec.{ts,js}',
'<rootDir>/packages/*/test/*-spec.{ts,js}'
],
testPathIgnorePatterns: [
'/coverage/',
'/docs/',
'<rootDir>/assets/',
'/examples/',
'<rootDir>/e2e/',
'<rootDir>/packages/*/dist',
'<rootDir>/packages/teraslice-cli/test/fixtures/'
],
collectCoverage: true,
collectCoverageFrom: [
'<rootDir>/packages/*/index.js',
'<rootDir>/packages/*/lib/*.js',
'<rootDir>/packages/*/lib/**/*.js',
'<rootDir>/packages/*/cmds/*.js',
'<rootDir>/packages/*/cmds/**/*.js',
'<rootDir>/packages/*/src/**/*.ts',
'<rootDir>/packages/*/src/*.ts',
'!<rootDir>/packages/**/*.json',
'!<rootDir>/packages/**/*.d.ts',
'!<rootDir>/packages/**/dist/**',
'!<rootDir>/packages/**/coverage/**'
],
coverageReporters,
coverageDirectory: '<rootDir>/coverage',
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
extensionsToTreatAsEsm: ['.ts'],
transform: {
['^.+\\.(t|j)sx?$']: ['@swc/jest',
{
jsc: {
loose: true,
parser: {
syntax: 'typescript',
tsx: false,
decorators: true
},
transform: {
legacyDecorator: true,
decoratorMetadata: true
},
target: 'esnext'
},
module: {
type: 'es6',
strictMode: false,
noInterop: false,
ignoreDynamic: true
}
}]
},
};