Sometimes, we want to fix TypeScript ts-jest not recognizing ES6 imports.
In this article, we’ll look at how to fix TypeScript ts-jest not recognizing ES6 imports.
How to fix TypeScript ts-jest not recognizing ES6 imports?
To fix TypeScript ts-jest not recognizing ES6 imports, we need to transform ES6 modules into something Jest can use.
For instance, we write
{
"jest": {
"transform": {
"^.+\\.jsx?$": "babel-jest",
"^.+\\.tsx?$": "ts-jest"
}
// ...
}
}
in our Jest config file to transform jsx
files with babel-jest
so they can be run with
"^.+\\.jsx?$": "babel-jest"
Conclusion
To fix TypeScript ts-jest not recognizing ES6 imports, we need to transform ES6 modules into something Jest can use.