From c47fcd7a445ba51c3d20fba2cdf08a28731c44af 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#2315 X-original-commit: a4a823041f0be76fff1a21b55b2c0ca792490515 Signed-off-by: RĂ©mi Rahir (rar) Signed-off-by: Minne Adrien (adrm) --- package.json | 2 +- tests/tsconfig.json | 7 +++++++ tsconfig.jest.json | 32 -------------------------------- 3 files changed, 8 insertions(+), 33 deletions(-) create mode 100644 tests/tsconfig.json delete mode 100644 tsconfig.jest.json diff --git a/package.json b/package.json index fbeb20d05b..b9715c5bf1 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,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..fd613c8bbb --- /dev/null +++ b/tests/tsconfig.json @@ -0,0 +1,7 @@ +{ + "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 - } -}