I personally don't see a lot of value in having type checking as part of the unit test task. I already have errors reported in my IDE, prepush hook and CI (I also disabled type checking in my build).
Disabling type checking in tests would allow running tests even when TS detects errors. It's a bit frustrating to have the tests failing because there is a unused variable for example...
I can understand that some people may disagree so what about adding a setting to enable/disable type checking in ts-jest?
isn't this what you're looking for? https://kulshekhar.github.io/ts-jest/user/config/diagnostics
UPDATE: I'm going to close this. If the link I gave you is not what you wanted, please reopen and explain ;-)
Thanks this is exactly what I was looking for. Sorry for missing that.
UPDATE: Actually I'm using isolatedModules after all.
Take care that isolatedModules does not allow all TS features, also isolatedModules is using ts.transpileModule which is creating an instance of a language service each time it is transforming a file
I didn't realize transpileModule had some limitations. It's working for us so I believe we are not using unsupported features. Would you still recommend using diagnostics: false over isolatedModules:true?
If you're doing type-checking by the side, I'd disable that and let type-checking be done by ts-jest so that you can --watch for better TDD (removing the diagnostics: false in that case). But that is my opinion/preference...
@huafu Does this work for TS 4?
I've the fol. packages and diagnostics: false stopped working after apugrading to TS 4.0.3
"ts-jest": "^26.4.1",
"typescript": "^4.0.3"
@avalanche1 if you can provide a repo which shows that it doesn't work, that would be helpful. I quickly checked mine but I see it works fine.
Most helpful comment
isn't this what you're looking for? https://kulshekhar.github.io/ts-jest/user/config/diagnostics
UPDATE: I'm going to close this. If the link I gave you is not what you wanted, please reopen and explain ;-)