Skip to content

Commit

Permalink
[IMP] test: make test tsconfig work in vscode
Browse files Browse the repository at this point in the history
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 #2297

Signed-off-by: Rémi Rahir (rar) <[email protected]>
  • Loading branch information
hokolomopo committed Apr 5, 2023
1 parent b95a7ed commit 3442c4f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
],
"globals": {
"ts-jest": {
"tsconfig": "tsconfig.jest.json"
"tsconfig": "tests/tsconfig.json"
}
}
},
Expand Down
10 changes: 10 additions & 0 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../build/js",
},
"include": [
"../src",
"."
]
}
32 changes: 0 additions & 32 deletions tsconfig.jest.json

This file was deleted.

0 comments on commit 3442c4f

Please sign in to comment.