You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a typescript package is compiled with type info, changes to the type info may be missed by ts-jest when the package is referenced from another package. Similar to #1747 but not identical.
To Reproduce
Steps to reproduce the behavior:
Unzip the attached zip file and follow the README.txt, which is copied inline here:
In the examplePackage folder, run:
yarn
yarn build
yarn link
In the consumerWithTest folder, run:
yarn
yarn link @example/package
yarn test
So far so good (the jestCache folder is created).
Now edit index.ts to uncomment b: number; and in the examplePackage folder, run:
yarn build
In the consumerWithTest folder, run:
yarn test
This should fail due to the change in type definition in index.ts, but passes.
Running yarn test --no-cache correctly identifies the problem.
Hi @ahnpnl. Other than the mention in #2696, I haven't seen any official acknowledgement of this bug. The other bug mentioned a design choice. Does that mean a significant redesign is in the works?
I would say yes, it鈥檚 quite a change, generally speaking is: moving type check to one phase earlier in transform process.
The current design is: collecting all dependencies to construct cache keys and let Jest handle when a file needs to be rechecked.
What I have in mind for a design change is: instead of letting Jest handle, we would always do type check before creating a Jest cache key (ofc only do this when user uses cache). Following this approach will technically solve issues but probably require a smart way of caching for ts-jest so that we only do type check for files which have been changed or when its dependencies have been changed.
For the record, I ended up working around this. I changed our build scripts to compile our test code with the TS compiler, not just the product code. We still use ts-jest to run the tests but the cache bug won't affect us because compilation errors are caught by the TS compiler.
馃悰 Bug Report
When a typescript package is compiled with type info, changes to the type info may be missed by ts-jest when the package is referenced from another package. Similar to #1747 but not identical.
To Reproduce
Steps to reproduce the behavior:
Unzip the attached zip file and follow the README.txt, which is copied inline here:
In the examplePackage folder, run:
yarn
yarn build
yarn link
In the consumerWithTest folder, run:
yarn
yarn link @example/package
yarn test
So far so good (the jestCache folder is created).
Now edit index.ts to uncomment
b: number;
and in the examplePackage folder, run:yarn build
In the consumerWithTest folder, run:
yarn test
This should fail due to the change in type definition in index.ts, but passes.
Running yarn test --no-cache correctly identifies the problem.
jestCacheIssue.zip
Expected behavior
Type info should be respected without clearing the cache
Link to repo (highly encouraged)
Debug log:
envinfo
The text was updated successfully, but these errors were encountered: