1、区分单元测试和集成测试
单元测试:每天对代码进行测试
集成测试:完成一个大需求或者是里程碑的时候团队进行测试
2、生成jest配置文件
npx jest --init
Would you like to use Typescript for the configuration file?
√ 是否要对配置文件使用Typescript,no
√ Choose the test environment that will be used for testing » jsdom
选择将用于测试的测试环境(browser-like)
√ Do you want Jest to add coverage reports?
是否要产生覆盖率文件
√ Automatically clear mock calls, instances and results before every test? …
在每次测试之前自动清除模拟调用、实例和结果,yes
执行后会生成coverage文件里面包含测试的报表