tsconfig-paths-jest

0.0.1 • Public • Published

tsconfig-paths-jest

This module loads tsconfig.json's paths and transforms to moduleNameMapper used in jest.config.js

Usage

tsconfig.json

"paths"{
  "@app/*": ["src/*"]
}

jest.config.js

const tsconfig = require("./tsconfig.json")
const moduleNameMapper = require("tsconfig-paths-jest")(tsconfig)
 
module.exports = {
  transform: {
    "^.+\\.tsx?$": "ts-jest",
  },
  testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
  moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
  moduleNameMapper,
}

Result

moduleNameMapper: {
  "@app/(.*)": "<rootDir>/src/$1"
}

Limitation

This module does not support the following definition that has multiple paths.

"paths": {
  "@app/*": ["src/*", "src/app/*"]
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.154,069latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.154,069

Package Sidebar

Install

npm i tsconfig-paths-jest

Weekly Downloads

54,069

Version

0.0.1

License

MIT

Unpacked Size

4.9 kB

Total Files

9

Last publish

Collaborators

  • ryohey