Last active
February 4, 2023 00:57
-
-
Save jweyrich/ae9d5f40e478988c5e8a15391ac6b6ca to your computer and use it in GitHub Desktop.
Example of Jest config with support for Path Mapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { pathsToModuleNameMapper } = require('ts-jest/utils'); | |
// In the following statement, replace `./tsconfig` with the path to your `tsconfig` file | |
// which contains the path mapping (ie the `compilerOptions.paths` option): | |
const { compilerOptions } = require('./tsconfig'); | |
module.exports = { | |
preset: 'ts-jest', | |
testEnvironment: 'node', | |
testMatch: ['**/tst/**/*.test.ts'], | |
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' }), | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "ES2020", | |
"module": "commonjs", | |
"moduleResolution": "node", | |
"sourceMap": true, | |
"emitDecoratorMetadata": true, | |
"experimentalDecorators": true, | |
"removeComments": false, | |
"noImplicitAny": false, | |
"declaration": true, | |
"baseUrl": ".", | |
"outDir": "build", | |
"typeRoots": ["node_modules/@types"], | |
"resolveJsonModule": true, | |
"paths": { | |
"@src/*": ["./src/*"], | |
"@tst/*": ["./tst/*"] | |
} | |
}, | |
"exclude": [ | |
"node_modules", | |
"jest.config.js" | |
], | |
"include": [ | |
"src/**/*", | |
"tst/*.ts", | |
"tst/**/*.test.ts" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment