2021-12-06
|~1 min read
|90 words
A natural follow up to Configuring Jest for Typescript with ts-jest, this Jest configuration write up is about configuring Jest to use native EcmaScript modules (ESM):
There are three steps:
tsconfig.json
jest.config.js
package.json
{
"target": "esnext",
"module": "esnext"
}
export default {
globals: {
"ts-jest": {
useESM: true,
},
},
}
{
"scripts": {
"tdd": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js --watch"
}
}
Kent C Dodds has an example repo and Rico Sta. Cruz has written other options too.
Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!