Skip to content

Commit

Permalink
chore: use tsconfig file to resolve jest typescript alias
Browse files Browse the repository at this point in the history
  • Loading branch information
Albert Hernandez Pellicer committed Jan 19, 2024
1 parent 31ebb3e commit 5930415
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { JestConfigWithTsJest } from "ts-jest";
import { pathsToModuleNameMapper } from "ts-jest";

import { compilerOptions } from "./tsconfig.json";

const MIN_COVERAGE = 80;

const config: JestConfigWithTsJest = {
Expand All @@ -21,9 +23,8 @@ const config: JestConfigWithTsJest = {
collectCoverageFrom: ["src/**/*.ts"],
setupFiles: ["<rootDir>.jest/set-env-vars.ts"],
clearMocks: true,
moduleNameMapper: pathsToModuleNameMapper({
"@src/*": ["src/*"],
}),
modulePaths: [compilerOptions.baseUrl],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths),
};

export default config;
7 changes: 4 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"outDir": "dist",
"sourceMap": true,
"inlineSources": true,
"resolveJsonModule": true,
"paths": {
"@src/*": ["src/*"],
},
"@src/*": ["src/*"]
}
},
"exclude": ["node_modules", "dist"],
"exclude": ["node_modules", "dist"]
}

0 comments on commit 5930415

Please sign in to comment.