Basic Jest and Typescript setup

Writing this up so I have somewhere to quickly grab basic Jest setup. This information is copied from the Jest Documentation Site compressed into just the parts I'm interested in.

Create folders

mkdir -p <project>/src
cd <project>

Install and init

npm init -y
npm install --save-dev jest  @babel/preset-typescript @types/jest @babel/preset-env @babel/preset-typescript
jest --init

Babel config file

Create a file called babel.config.js in the project root folder with the contents:

module.exports = {
  presets: [
    ["@babel/preset-env", { targets: { node: "current" } }],
    "@babel/preset-typescript",
  ],
};

Test script

Add a test script to package.json to easily run Jest in watch mode.

"test": "jest --watchAll"