Files
ProjetBut3/backend/jest.config.ts
T

31 lines
848 B
TypeScript
Raw Normal View History

2026-11-03 16:21:56 +01:00
import type { Config } from 'jest';
import { pathsToModuleNameMapper } from 'ts-jest';
import ts from 'typescript';
// Path aliases (e.g. the ones added by `nest g library`) live in tsconfig.json,
// so they are read from there instead of being duplicated here.
const { config: tsconfig } = ts.readConfigFile(
'./tsconfig.json',
ts.sys.readFile,
);
const paths = tsconfig?.compilerOptions?.paths ?? {};
const config: Config = {
moduleFileExtensions: ['js', 'json', 'ts'],
rootDir: '.',
testRegex: '.*\\.spec\\.ts$',
transform: {
'^.+\\.(t|j)s$': 'ts-jest',
},
moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '<rootDir>/' }),
collectCoverageFrom: [
'src/**/*.(t|j)s',
'libs/**/*.(t|j)s',
'apps/**/*.(t|j)s',
],
coverageDirectory: './coverage',
testEnvironment: 'node',
};
export default config;