-
-
Notifications
You must be signed in to change notification settings - Fork 629
Expand file tree
/
Copy pathjest.config.base.js
More file actions
50 lines (43 loc) · 1.66 KB
/
Copy pathjest.config.base.js
File metadata and controls
50 lines (43 loc) · 1.66 KB
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
import { createJsWithTsPreset } from 'ts-jest';
const tsconfig = {
// Relative imports in our TS code include `.ts` extensions.
// When compiling the package, TS rewrites them to `.js`,
// but ts-jest runs on the original code where the `.js` files don't exist,
// so this setting needs to be disabled here.
rewriteRelativeImportExtensions: false,
// Override hybrid module kind (Node16/NodeNext) to avoid ts-jest warning
// about requiring isolatedModules: true
module: 'ESNext',
};
const tsJestPreset = createJsWithTsPreset({
tsconfig,
});
// Global Jest configuration for the monorepo
// Contains common settings that all packages inherit
export default {
// === TypeScript Configuration ===
// ts-jest preset with custom TypeScript settings, extended to handle .cts/.mts files
...tsJestPreset,
transform: {
...tsJestPreset.transform,
// Extend transform to include CommonJS TypeScript (.cts) and ES Module TypeScript (.mts) files
'^.+\\.[cm]?ts$': [
'ts-jest',
{
tsconfig,
},
],
},
// === Test Environment Configuration ===
testEnvironment: 'jsdom',
// === Common Test Patterns ===
// Default test pattern - packages can override this
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
// Clear mock call history (calls, instances, results, contexts) between tests.
// Mock implementations from mockReturnValue/mockImplementation persist.
// Use resetMocks: true when implementation reset is required.
clearMocks: true,
// === Common Module File Extensions ===
// Include cts/mts for CommonJS/ES module TypeScript files
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'cts', 'mts', 'json'],
};