-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjest.config.cjs
More file actions
50 lines (50 loc) · 2 KB
/
Copy pathjest.config.cjs
File metadata and controls
50 lines (50 loc) · 2 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
// jest.config.js
module.exports = {
testEnvironment: 'node', // Use node environment for main process tests
preset: 'ts-jest',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: 'tsconfig.test.json',
diagnostics: {
ignoreCodes: [2307],
},
},
], // Transform TypeScript files using ts-jest
'^.+\\.jsx?$': 'babel-jest', // Transform JS files using Babel
},
// Optional: Mock CSS/image imports if they cause errors
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
'^@shared/(.*)\\.js$': '<rootDir>/src/shared/$1',
'^@shared/(.*)$': '<rootDir>/src/shared/$1',
'^@renderer/(.*)\\.js$': '<rootDir>/src/renderer/src/$1',
'^@renderer/(.*)$': '<rootDir>/src/renderer/src/$1',
'\\.(css|less|sass|scss)$': 'identity-obj-proxy', // Mocks CSS module imports
'\\.(gif|ttf|eot|svg|png)$': '<rootDir>/__mocks__/fileMock.js', // Mocks file imports
},
// Optional: Setup file to run before tests (e.g., global mocks)
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
// Specify the directory where your source files are located
roots: ['<rootDir>/src'], // Adjust if your source files are elsewhere
// Specify the test file pattern
testMatch: ['**/__tests__/**/*.?(m)[jt]s?(x)', '**/?(*.)+(spec|test).?(m)[jt]s?(x)'],
// Collect coverage from source files, excluding certain patterns
collectCoverageFrom: [
'src/**/*.{js,jsx,ts,tsx}', // Adjust to match your source structure
'!src/**/*.d.ts',
'!src/main.ts', // Exclude main process file
'!src/preload.ts', // Exclude preload scripts
'!src/**/*.test.{js,jsx,ts,tsx}', // Exclude test files themselves
'!src/**/index.ts', // Exclude index barrels if any
// Add other files/patterns to exclude from coverage
],
coverageDirectory: 'coverage',
coverageReporters: ['text', 'lcov', 'clover'],
coveragePathIgnorePatterns: [
'<rootDir>/src/renderer/',
'<rootDir>/src/shared/types/global.d.ts',
'<rootDir>/src/shared/types/global-main.d.ts',
],
};