https://github.com/joscha/ts-jest-transformer-example
Custom transformer & module mapper with jest & ts-jest
https://github.com/joscha/ts-jest-transformer-example
identity-obj-proxy jest module-mapper react testing transformer ts-jest typescript
Last synced: about 1 month ago
JSON representation
Custom transformer & module mapper with jest & ts-jest
- Host: GitHub
- URL: https://github.com/joscha/ts-jest-transformer-example
- Owner: joscha
- License: mit
- Created: 2017-03-14T07:54:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-14T12:34:22.000Z (over 9 years ago)
- Last Synced: 2025-06-05T05:07:19.937Z (about 1 year ago)
- Topics: identity-obj-proxy, jest, module-mapper, react, testing, transformer, ts-jest, typescript
- Language: TypeScript
- Size: 31.3 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Example: Custom transformer & module mapper with jest & ts-jest
This repository shows how to use custom transformers and module mappers with [jest](https://facebook.github.io/jest/) when using [ts-jest](https://github.com/kulshekhar/ts-jest).
It also shows especially how this works when there is a custom tsconfig to be used for the test environment.
## Examples
Have a look at
* `./tools/fileTransformer.js` to see how to write a transformer using [`ts-jest-transformer`](https://github.com/joscha/ts-jest-transformer)
* `./tools/stubProxy.ts` to see how to write a module mapper
* `./tools/identityProxy.ts` to see how to use the `identity-obj-proxy` in a module mapper
### Caveats
* Transformers can not be written in TypeScript, because they are picked up by ts-jest and are not transpiled
* Module mappers have to be written in TypeScript, so the exports end up in the right place
* Put your transformers *before* the `ts-jest` preprocessor
## Development
Run `yarn dev` to run the sample test with a disabled jest cache. Have a look at `./tmp` to see the generated files (helps you with debugging)