const { defaults : tsPreset } = require ( 'ts-jest/presets' ) ; const { pathsToModuleNameMapper } = require ( 'ts-jest' ) ; const { getJestCachePath } = require ( '../../cache.config' ) ; const packageJson = require ( './package.json' ) ; const { compilerOptions : baseTsConfig } = require ( './tsconfig.json' ) ; const getTsConfigBasePaths = ( ) => { return baseTsConfig . paths ? pathsToModuleNameMapper ( baseTsConfig . paths , { prefix : '<rootDir>/' , } ) : { } ; } ; typedef { import ( 'ts-jest/dist/types' ) } type { import ( '@jest/types' ) . Config . InitialOptions } const config = { name : `${ packageJson . name }:unit` , cacheDirectory : getJestCachePath ( packageJson . name ) , testEnvironment : 'jsdom' , verbose : true , rootDir : './src' , transform : { ... tsPreset . transform , } , setupFilesAfterEnv : [ '@testing-library/jest-dom/extend-expect' ] , testMatch : [ '<rootDir>/**/*.{spec,test}.{js,jsx,ts,tsx}' ] , moduleNameMapper : { '^@/test-utils$' : '<rootDir>/../config/jest/test-utils' , '.+\\.(css|styl|less|sass|scss)$' : 'jest-css-modules-transform' , '\\.svg$' : '<rootDir>/../config/jest/__mocks__/react-svgr-mock.js' , ... getTsConfigBasePaths ( ) , } , collectCoverage : false , coverageDirectory : '<rootDir>/../coverage' , collectCoverageFrom : [ '<rootDir>/**/*.{ts,tsx,js,jsx}' , '!**/*.test.ts' ] , globals : { 'ts-jest' : { diagnostics : true , tsconfig : './tsconfig.jest.json' , } , } , } ; module . exports = config ;