ts-jest: With cached results, changes to type definitions are not detected
Issue :
Given a type declaration in core code, and a reference to that type definition in jest code, type-safety is not always enforced.
Expected behavior :
Changes to type definitions should be detected (failing to compile where appropriate).
Minimal repo :
- Unzip the attached zip file and run yarn and then yarn test (should succeed).
- Change the type definition in thing.ts to contain
b: number - Run yarn test again. Due to the cache, it succeeds and should not. It will (correctly) fail if you remove the cache folder “jestCache”
thing.ts contains:
export type Thing = {
a: number;
// b: number;
};
thing.test.ts contains:
export const thing: Thing = { a: 1 };
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 9
- Comments: 24 (1 by maintainers)
Commits related to this issue
- fix(compiler): resolve nested imported modules for each processing file (#2436) Related to #1390 and #1747 — committed to kulshekhar/ts-jest by ahnpnl 3 years ago
- Merge #3534 3534: Bump ts-jest from 26.5.2 to 26.5.4 in /tests r=mergify[bot] a=dependabot[bot] Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.2 to 26.5.4. <details> <summary>Chang... — committed to comit-network/comit-rs by bors[bot] 3 years ago
- Bump ts-jest from 26.5.3 to 26.5.4 Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com... — committed to pravinbashyal/epubinator by dependabot[bot] 3 years ago
- chore(deps-dev): Bump ts-jest from 26.5.3 to 26.5.4 (#95) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a h... — committed to cdktf/cdktf-provider-project by dependabot[bot] 3 years ago
- chore(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 (#255) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a ... — committed to cdktf/cdktf-provider-null by dependabot[bot] 3 years ago
- chore(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 (#270) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a ... — committed to cdktf/cdktf-provider-kubernetes by dependabot[bot] 3 years ago
- chore(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 (#260) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a ... — committed to cdktf/cdktf-provider-docker by dependabot[bot] 3 years ago
- chore(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 (#278) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a ... — committed to cdktf/cdktf-provider-google by dependabot[bot] 3 years ago
- chore(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 (#266) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a ... — committed to cdktf/cdktf-provider-github by dependabot[bot] 3 years ago
- chore(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 (#267) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a ... — committed to cdktf/cdktf-provider-azurerm by dependabot[bot] 3 years ago
- build(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 (#269) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a ... — committed to cdktf/cdktf-provider-aws by dependabot[bot] 3 years ago
- chore(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 (#309) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a ... — committed to wheatstalk/cdk-ecs-website by mergify[bot] 3 years ago
- build(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 (#193) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a ... — committed to trexcoe/smile-jenkins by mergify[bot] 3 years ago
- chore(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 (#141) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a ... — committed to taimos/lambda-toolbox by mergify[bot] 3 years ago
- chore(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 (#141) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a ... — committed to taimos/taimos-projen by mergify[bot] 3 years ago
- chore(deps-dev): Bump ts-jest from 26.5.3 to 26.5.4 (#158) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a ... — committed to SnapPetal/cdk-simplewebsite-deploy by dependabot[bot] 3 years ago
- chore(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 (#53) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a h... — committed to wheatstalk/xenu-checker by mergify[bot] 3 years ago
- chore(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 (#77) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a h... — committed to wchaws/effective-cdk by mergify[bot] 3 years ago
- Merge #101 101: chore(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 r=aDotInTheVoid a=dependabot[bot] Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary... — committed to aDotInTheVoid/xmark-js by bors[bot] 3 years ago
- chore(deps-dev): bump ts-jest from 26.5.3 to 26.5.4 (#419) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.3 to 26.5.4. <details> <summary>Changelog</summary> <p><em>Sourced from <a ... — committed to cdklabs/jsii-srcmak by dependabot[bot] 3 years ago
I also have the same issue, it is so annoying, we had to disable the cache to prevent errors. Please fix this issue.
So far it seems to do the job. I made a new test which attempts to dereference an invalid property on a class. Once the test suite runs, I see a failure as expected. Upon making a change to the source code and waiting for the test suite to rerun ts-jest now properly sees the newly create property in the class and the test passes as expected.
I ran jest with --watch and --watchAll same results.
OK, your fix looks good in watch mode. Starting with the original zip file (but upgraded to 25.3.0), I verified that running
yarn test --watchAllfailed to detect changes in watch mode as expected.yarn test --watchAllThingtype, even deleting it, and then restoring it.LGTM 😃
I’ll try to publish a new version tomorrow
the fix will be in the next release version. Please wait 😃
Note: watch mode fix isn’t included in the fix for this issue. Watch mode seems to be more complex to come up with the fix. For watch mode, please follow #943 for the update.
cc @kulshekhar
Running into the same issue here. Using --no-cache doesn’t alleviate the issue for me. The only out for me was to just not use ts-jest at all. And fall back to jest’s babel configuration as described here.
Yeah @drrnkin, I know that feeling too. I posted it because we were having some issues with errors in our tests, that were detected in CI but not in our local development environment.
We are workarounding this issue by passing
--no-cacheflag tojest