[英]How do I run Jest test from specific folder only neglecting other folder test?
I have a node js project and it have 2 test folders.我有一个节点 js 项目,它有 2 个测试文件夹。 There are app & admin folder inside of src/ test /v1.
src/ test /v1 里面有 app & admin 文件夹。 I want script to run test from only app folder.
我希望脚本仅从 app 文件夹运行测试。 I tried using
jest app
, jest app --testPathPattern=src/__test__/v1/app"
but both didn't worked.我尝试使用
jest app
, jest app --testPathPattern=src/__test__/v1/app"
但两者都没有奏效。
By default jest will try to run all tests recursively of the root directory (where package.json is)默认情况下,jest 将尝试递归运行根目录的所有测试(其中 package.json 是)
To specify a specific folder via CLI:通过 CLI 指定特定文件夹:
jest --testPathPattern=src/test/v1/app
You can also setup package.json to have specific test commands for running tests for specific folders:您还可以设置 package.json 以使用特定的测试命令来运行特定文件夹的测试:
"scripts": {
"test:app": "jest --testPathPattern=src/test/v1/app",
"test:admin": "jest --testPathPattern=src/test/v1/admin",
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.