jest-tutorial
jest-tutorial copied to clipboard
pathsToModuleNameMapper 可以直接从 ts-jest 里面引入了
https://kulshekhar.github.io/ts-jest/docs/getting-started/paths-mapping/
const { pathsToModuleNameMapper } = require('ts-jest')
// 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')
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
// [...]
roots: ['<rootDir>'],
modulePaths: [compilerOptions.baseUrl], // <-- This will be set to 'baseUrl' value
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths /*, { prefix: '<rootDir>/' } */),
}