Jest and Typescript config


Configuring Jest
https://jestjs.io/docs/configuration


I think need to exclude jest config from package.json


And run tests command like:

"test": "NODE_PATH=./src jest --config ./test/jest-e2e.json"


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/index.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