Jest and Typescript config


Based on video course [FrontendMasters] Production-Grade TypeScript


Configured project :
https://github.com/mike-north/professional-ts-my-lib


$ npm install --save-dev \
    jest @types/jest \
    @babel/preset-env \
    @babel/preset-typescript


$ mkdir tests


$ vi tests/intex.test.ts


content

https://github.com/mike-north/professional-ts-my-lib/blob/master/tests/index.test.ts


$ vi tests/tsconfig.json
{
  "extends": "../tsconfig.json",
  "references": [
    {
      "name": "my-lib",
      "path": ".."
    }
  ],
  "compilerOptions": {
    "types": ["jest"],
    "rootDir": "..",
    "noEmit": true
  },
  "include": ["."]
}


.babelrc

{
  "presets": [
    ["@babel/preset-env", { "targets": { "node": 10 } }],
    "@babel/preset-typescript"
  ]
}


$ npm run lint
$ npm run test