Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/HosseinAgha/tsconfig-paths-jest-mapper
Generates Jest moduleNameMappers from TSConfig's paths
https://github.com/HosseinAgha/tsconfig-paths-jest-mapper
jest jest-config tsconfig-paths typescript
Last synced: about 1 month ago
JSON representation
Generates Jest moduleNameMappers from TSConfig's paths
- Host: GitHub
- URL: https://github.com/HosseinAgha/tsconfig-paths-jest-mapper
- Owner: HosseinAgha
- License: mit
- Created: 2019-09-25T08:43:42.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-13T05:14:12.000Z (over 3 years ago)
- Last Synced: 2024-11-11T20:25:24.021Z (about 2 months ago)
- Topics: jest, jest-config, tsconfig-paths, typescript
- Language: JavaScript
- Size: 388 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![NPM ndb package](https://img.shields.io/npm/v/tsconfig-paths-jest-mapper)](https://www.npmjs.com/package/tsconfig-paths-jest-mapper)
[![CircleCI](https://circleci.com/gh/HosseinAgha/vscode-open-react-component-style.svg?style=svg)](https://circleci.com/gh/HosseinAgha/vscode-open-react-component-style)Convert your tsconfig paths to jest `moduleNameMappers`.
This introduces many bug fixes and improvements to [archived](https://github.com/ryohey/tsconfig-paths-jest) [tsconfig-paths-jest](https://www.npmjs.com/package/tsconfig-paths-jest) package.## Usage
In your `jest.config.js` file:
```javascript
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:
```javascript
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. `true` by default.