This repository shows how to use custom transformers and module mappers with jest when using ts-jest.
It also shows especially how this works when there is a custom tsconfig to be used for the test environment.
Have a look at
./tools/fileTransformer.jsto see how to write a transformer usingts-jest-transformer./tools/stubProxy.tsto see how to write a module mapper./tools/identityProxy.tsto see how to use theidentity-obj-proxyin a module mapper
- 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-jestpreprocessor
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)