Article directory
illustrate
We can already use jest to unit test js, but currently the more popular one is ts, so how do we use jest to test ts?
The official website gives two methods:
1. Use babel+typescript to compile and test (this method requires a lot of configuration, and several files need to be updated simultaneously during the update. So it is not recommended) 2. Use jest
directly Integration package @types/jest, but it should also be explained here
*@types/jest是在DefinitelyTyped中维护的第三方库,因此可能还没有涵盖最新的jest特性或版本。尽量匹配Jest和@types/ Jest的版本。例如,如果你使用的是Jest 27.4.0,那么就安装27.4。@types/jest的X是理想的
*
1 Install @types/jest
2 tests
Of course, we can also test the writing method of class class, which also satisfies cmd