ts-jest: TypeError: Jest: a transform must export something.
🐛 Bug Report
After upgrading from jest 23.6.3 to 27.0.1 and running our test suite we get the following error message:
TypeError: Jest: a transform must export something.

To Reproduce
- Clone the GIT repo
- Upgrade jest:
name range from to url
>( ) jest latest 26.6.3 ❯ 27.0.1 https://jestjs.io/
- Run yarn test
Expected behavior
No error message
Debug log:
# content of ts-jest.log :
{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"26.5.6"},"message":"creating jest presets not handling JavaScript files","sequence":1,"time":"2021-05-25T13:21:43.451Z"}
{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"26.5.6"},"message":"creating jest presets not handling JavaScript files","sequence":2,"time":"2021-05-25T13:21:43.474Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","version":"26.5.6"},"message":"creating Importer singleton","sequence":3,"time":"2021-05-25T13:21:45.906Z"}
envinfo
System:
OS: Windows Server 2016
Node version: 14.15.4
Npm packages:
jest: 27.0.1
ts-jest: 26.5.6
typescript: 4.2.4
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 50
- Comments: 29
Commits related to this issue
- Downgrade ts-jest to 26.x v27 was causing some issues that don't seem to have an easy workaround yet: https://github.com/kulshekhar/ts-jest/issues/2612 — committed to concord-consortium/tectonic-explorer by pjanik 3 years ago
- Update js-test to 27.0.0 Running tests failed after updating jest to over 27.0.0 because of the issue described here: https://github.com/kulshekhar/ts-jest/issues/2612 To fix this issue, we need to ... — committed to octodemo/pr-gatekeeper by yuichielectric 3 years ago
- chore(deps): Bump ts-jest from 26.5.4 to 27.0.3 This is required to update Jest to 27.x. See: - https://github.com/kulshekhar/ts-jest/issues/2612#issuecomment-848587164 — committed to guardian/cdk by akash1810 3 years ago
- Update ts-jest to fix incompatibility with jest 27.x. See https://github.com/kulshekhar/ts-jest/issues/2612 — committed to gradle-update/update-gradle-wrapper-action by cristiangreco 3 years ago
- Upgrade jest to latest version Dependabot Jest upgrade PR cause all tests to fail Manually do upgrade with fix for Jest tests: - 'ts-jest' version required upgrade: https://github.com/kulshekhar/ts-... — committed to nationalarchives/tdr-transfer-frontend by TomJKing 3 years ago
- Updated ts-jest to fix "TypeError: Jest: a transform must export something." https://github.com/kulshekhar/ts-jest/issues/2612 — committed to brianpilati/td-ameritrade by brianpilati 3 years ago
- Clear cache when running Jest Supposed to fix https://github.com/airbrake/airbrake-js/pull/1141/checks?check_run_id=3940914643 according to https://github.com/kulshekhar/ts-jest/issues/2612#issuecom... — committed to airbrake/airbrake-js by kyrylo 3 years ago
pls clear Jest cache and use
ts-jest27.0.0adding to the previous comment – clearing the cache didn’t solve the issue for me. I’m still getting the original error mentioned in this thread.
You should clear Jest cache via
jest —clearCacheNot sure if it will help, but I had this issue because my version of jest globally differed from the version in the project I was working on. Running
sudo npm i -g jest@latestresolved the issue for me.Met the same issue with
"jest": "^27.0.1"and fixed by revert to"jest": "^26.4.2",.You have to use ts-jest 27.0.1 and clear jest cache @Jeff-Tian
Thank you for the feedback. It might be a good idea to keep one of the issues open so it’s easy to find. That’s why I thought it wasn’t an issue anymore as it was closed.
In my case I had
jestandts-jestboth installed in 27.x.x, but an old version ofreact-scriptswas referencing v26 which caused the issue:Exactly the same here, clear cache, re-installing
node_modules, another developer checking out on fresh machine, no cigar. Downgrading worked first time.@asohail-futu check the version of
jestyou are using. In my case the issue was that I was using jest v26 with ts-jest v27. I was not installing jest directly, it was a dependency from Create React App. Maybe you are having the same issue!fixed by upgrading
jestto^27.2.1for meClearing cache & reinstalling did not help me, but upgrading
jest-clito^27.2.1did.there is never a compatibility support before. Major version of
ts-jestalways follows Jest major version.how about remove
node_modulesand reinstall? I think Jest is readingts-jestfrom another dependency not direct dependency.Please make sure that there are no other dependencies using
ts-jest26, otherwise Jest will keep loading that version instead of your directts-jest27 dep.