From e90b52dc4b782bde614b7513a5acbd7e8ad3c178 Mon Sep 17 00:00:00 2001 From: Akash Askoolum Date: Mon, 24 May 2021 14:24:11 +0100 Subject: [PATCH] chore: Use custom `tsconfig` for `ts-jest` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default, `ts-jest` will use `tsconfig.json` for TypeScript configuration. Our `tsconfig.json` sets `noUnusedLocals` to `true`. This means compilation will fail if we import something and don't use it. If you're running tests locally (using `script/start`, for example) and comment out a block of code that results in an import not being used, a compile error will result and the tests will not run until resolved. In reality you are going to use it, so you end up temporarily commenting out the import (once you've expanded them as the IDE collapses them 😅) This whole process is slow. In this change we instruct `ts-jest` to use a custom configuration, specifically allowing unused locals. This results in `jest` no longer complaining about unused imports and a faster feedback loop. Unused locals will continue to get caught in the compile and lint steps, which are run in CI. That is, this change simply improves the experience when running the tests. See: - https://www.typescriptlang.org/tsconfig#noUnusedLocals - https://huafu.github.io/ts-jest/user/config/tsConfig --- jest.config.js | 5 +++++ tsconfig.test.json | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 tsconfig.test.json diff --git a/jest.config.js b/jest.config.js index e7a5668155..7de7998277 100644 --- a/jest.config.js +++ b/jest.config.js @@ -16,4 +16,9 @@ module.exports = { - #448 */ modulePathIgnorePatterns: ["/lib"], + globals: { + "ts-jest": { + tsconfig: "tsconfig.test.json", + }, + }, }; diff --git a/tsconfig.test.json b/tsconfig.test.json new file mode 100644 index 0000000000..977510361c --- /dev/null +++ b/tsconfig.test.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noUnusedLocals": false + } +}