-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.config.js
More file actions
29 lines (27 loc) · 1.04 KB
/
jest.config.js
File metadata and controls
29 lines (27 loc) · 1.04 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
const { pathsToModuleNameMapper } = require('ts-jest');
const fs = require('fs');
// Verifica que tsconfig.json existe antes de requerirlo
const tsConfig = fs.existsSync('./tsconfig.json') ? require('./tsconfig.json') : {};
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/src/test/jest-setup.ts'],
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
roots: ['<rootDir>'],
maxWorkers: '50%',
cacheDirectory: '<rootDir>/.jest-cache',
globals: {
'ts-jest': {
diagnostics: false,
isolatedModules: true,
},
},
modulePaths: tsConfig.compilerOptions ? [tsConfig.compilerOptions.baseUrl] : [],
moduleNameMapper: {
...(tsConfig.compilerOptions && tsConfig.compilerOptions.paths
? pathsToModuleNameMapper(tsConfig.compilerOptions.paths, { prefix: '<rootDir>/' })
: {}),
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js',
'\\.(css)$': 'identity-obj-proxy'
}
};