Jest测试初学(三)--Jest 命令行工具的使用

当你运行 运行 npm run test 的时候,会出现一些提示语
提示语
这些其实是可以选择测试的模式

一 Watch Usage的介绍

› Press f to run only failed tests. 按f键只运行失败的测试
› Press o to only run tests related to changed files.

  • 如果要用jest,可以用git管理代码,两者之间有绑定关系
  • 按o键,只运行与更改文件相关的测试
  • 修改配置,直接进入o模式
  "scripts": {
    "test": "jest --watch",
    "coverage": "jest --coverage"
  },

› Press p to filter by a filename regex pattern. 按p按文件名regex模式进行筛选

› Press t to filter by a test name regex pattern. 按t按测试名称regex模式进行筛选

› Press q to quit watch mode. 按q监测退出模式

› Press Enter to trigger a test run. 按Enter键触发测试运行

猜你喜欢

转载自blog.csdn.net/xiaoyangzhu/article/details/101169901