最近学习了一下单元测试,每次执行命令的时候都会将全部的测试文件重新来一遍,在网上也稍微找了一下,大部分都是jest的使用流程,和我的需要很不吻合,经过测试发现后, 以下有几种方式可行,可供参考:
- 使用yarn
yarn jest ./tests/unit/components/*.spec.js
- 使用npm
使用之前需要在根目录下的package.json配置
"test": "jest"
,然后 npm test ./tests/unit/components/*.spec.js 即可
- jest全路径
node_modules/jest/bin/jest.js ./tests/unit/components/*.spec.js
网友评论