1.4.0 • Published 5 years ago

tsconfig-paths-jest-mapper v1.4.0

Weekly downloads
175
License
MIT
Repository
github
Last release
5 years ago

Convert your tsconfig paths to jest moduleNameMappers.
This introduces many bug fixes and improvements to archived tsconfig-paths-jest package.

Usage

In your jest.config.js file:

const getJestMappersFromTSConfig = require('tsconfig-paths-jest-mapper');
const moduleNameMapper = getJestMappersFromTSConfig();

module.exports = {
  moduleNameMapper,
  // ... other configs
}

It assumes you have tsconfig besides your jest.config.js file.
You can also provide the path to your tsconfig if it is in a non-standard location:

const path = require('path');
const getJestMappersFromTSConfig = require('tsconfig-paths-jest-mapper');
const tsconfigPath = path.resolve(__dirname, '../../tsconfig.json');
const moduleNameMapper = getJestMappersFromTSConfig(tsconfigPath);

module.exports = {
  moduleNameMapper,
  // ... other configs
}

Options

  • startsWith: ensures that all the replaced paths (keys in the tsconfig) happen at the beginning of the path. is true by default.
1.4.0

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago