From f0a55aaa35c4890b3019adedc2bfdf2bccbb235f Mon Sep 17 00:00:00 2001 From: Tancredi Trugenberger Date: Mon, 8 Feb 2021 20:08:25 +0000 Subject: [PATCH] Add testing ts config, add typechecking CI step --- .github/workflows/test.yaml | 1 + package.json | 8 +++++++- tsconfig.json | 5 ++--- tsconfig.test.json | 6 ++++++ 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 tsconfig.test.json diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5825feb2..dd733b8b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -26,6 +26,7 @@ jobs: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} - run: npm ci - run: npm run lint + - run: npm run typecheck test: if: "!contains(github.event.head_commit.message, 'skip ci')" diff --git a/package.json b/package.json index 24223a8d..20b1475b 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "test": "jest", "build": "rimraf lib && tsc --project ./tsconfig.json", "watch": "npm run build -- --watch", + "typecheck": "tsc --noEmit --project tsconfig.test.json --noEmit", "lint": "prettier --check ." }, "files": [ @@ -68,7 +69,12 @@ "jest": { "preset": "ts-jest", "testEnvironment": "node", - "rootDir": "./src" + "rootDir": "./src", + "globals": { + "ts-jest": { + "tsconfig": "./tsconfig.test.json" + } + } }, "engines": { "node": ">= 10.0.0" diff --git a/tsconfig.json b/tsconfig.json index cc3d4442..0a83f51e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "rootDir": "src", "sourceMap": true, "target": "ES6", - "types": ["node", "jest"] + "types": ["node"] }, "typeRoots": ["node_modules/@types"], "exclude": [ @@ -17,6 +17,5 @@ "lib", "src/**/__mocks__/*.ts", "src/**/__tests__/*.ts" - ], - "include": ["src/**/*.ts"] + ] } diff --git a/tsconfig.test.json b/tsconfig.test.json new file mode 100644 index 00000000..45a73a4d --- /dev/null +++ b/tsconfig.test.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { "noEmit": true, "types": ["node", "jest"] }, + "exclude": ["node_modules"], + "include": ["src/**/__mocks__/*.ts", "src/**/__tests__/*.ts"] +}