Jest Setup for a Monorepo
Updated: January 15, 2021
Out of the box, Jest mostly works in a Monorepo environment, with the exception of a few Babel plugins so that (as an example) TypeScript works.
Needs:
@babel/preset-env
(Babel will transform whatever it needs to transform based on the build target, e.g. TypeScript, IE11, ES6, Node10, etc.)@babel/preset-typescript
(Babel will strip out the symbols that are specific to TypeScript)
The root-level .babelrc
file would look like:
{
"presets": [
["@babel/preset-env", { "targets": { "node": 10 } }],
"@babel/preset-typescript"
]
}
The target above is arbitrary, and can be anything (or nothing).