Skip to content

Instantly share code, notes, and snippets.

@luminuszz
Created August 28, 2021 17:39
Show Gist options
  • Save luminuszz/2ddb189c21ef33d833491acf1ce9120c to your computer and use it in GitHub Desktop.
Save luminuszz/2ddb189c21ef33d833491acf1ce9120c to your computer and use it in GitHub Desktop.
Setup jest config for resolve ts-paths
/* eslint-disable @typescript-eslint/no-var-requires */
const { pathsToModuleNameMapper } = require('ts-jest/utils')
const { compilerOptions } = require('./tsconfig.json')
module.exports = {
setupFiles: ['dotenv/config'],
clearMocks: true,
verbose: true,
collectCoverage: true,
preset: 'ts-jest',
collectCoverageFrom: [
'<rootDir>/src/modules/**/services/*.ts',
'<rootDir>/src/modules/**/controllers/*.ts',
'<rootDir>/src/**/**/*.pipe.ts',
],
coverageDirectory: 'coverage',
coverageReporters: ['text-summary', 'lcov'],
testEnvironment: 'node',
testMatch: ['**/*.spec.ts'],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>',
}),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment