From 3442c4f9e983ef11e19fddc533f403327a0b9243 Mon Sep 17 00:00:00 2001 From: "Adrien Minne (adrm)" Date: Fri, 31 Mar 2023 08:51:05 +0000 Subject: [PATCH] [IMP] test: make test tsconfig work in vscode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The root tsconfig.json file don't include the tests files, to not waste time compiling the tests when it's not needed. Another tsconfig file `tsconfig.test.json` was added in 09863df, to give as argument to jest to compile the tests. This file is however not used by VSCode to find errors in the tests files, and some default ts configuration was used instead. This led to mismatch between the errors appearing in the IDE, and errors when running the tests. The two most common errors in VSCode were: - custom jest matcher (eg. `toBeCancelledBecause`) not found - strict type checking in `test.each` arguments leading to errors This commit fix the issue by adding a `test/tsconfig.json` file, which extends the root `tsconfig.json` file, and is used by both jest and VSCode. Note that the tests run fine without giving this file to jest, because the root `tsconfig.json` file is used, and the jest matcher are defined with `setupFilesAfterEnv` in `package.json`. Odoo task 3255953 closes odoo/o-spreadsheet#2297 Signed-off-by: RĂ©mi Rahir (rar) --- package.json | 2 +- tests/tsconfig.json | 10 ++++++++++ tsconfig.jest.json | 32 -------------------------------- 3 files changed, 11 insertions(+), 33 deletions(-) create mode 100644 tests/tsconfig.json delete mode 100644 tsconfig.jest.json diff --git a/package.json b/package.json index 40f0695921..e85bb525c6 100644 --- a/package.json +++ b/package.json @@ -112,7 +112,7 @@ ], "globals": { "ts-jest": { - "tsconfig": "tsconfig.jest.json" + "tsconfig": "tests/tsconfig.json" } } }, diff --git a/tests/tsconfig.json b/tests/tsconfig.json new file mode 100644 index 0000000000..c8024a780b --- /dev/null +++ b/tests/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../build/js", + }, + "include": [ + "../src", + "." + ] +} diff --git a/tsconfig.jest.json b/tsconfig.jest.json deleted file mode 100644 index fd28876f07..0000000000 --- a/tsconfig.jest.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "preserveConstEnums": true, - "noImplicitThis": true, - "moduleResolution": "node", - "removeComments": false, - "target": "es2019", - "outDir": "dist", - "alwaysStrict": true, - "noUnusedLocals": true, - "noUnusedParameters": false, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "strictPropertyInitialization": true, - "strictNullChecks": true, - "esModuleInterop": true, - "allowJs": true, - "sourceMap": true - }, - "include": ["src", "tests"], - "typedocOptions": { - "entryPoints": ["src/index.ts"], - "out": "doc/tsdoc", - "name": "o-spreadsheet API", - "readme": "none", - "excludePrivate": true, - "hideGenerator": true, - "disableSources": true, - "excludeExternals": true - } -}