codethrasher

Jest Setup for a Monorepo

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:

  1. @babel/preset-env (Babel will transform whatever it needs to transform based on the build target, e.g. TypeScript, IE11, ES6, Node10, etc.)
  2. @babel/preset-typescript (Babel will strip out the symbols that are specific to TypeScript)

The root-level .babelrc file would look like:

1
2
3
4
5
6
{
    "presets": [
        ["@babel/preset-env", { "targets": { "node": 10 } }],
        "@babel/preset-typescript"
    ]
}

The target above is arbitrary, and can be anything (or nothing).

← Monorepos Composite Builds →