Categories
TypeScript Answers

How to fix TypeScript ts-jest not recognizing ES6 imports?

Spread the love

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.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.