更新时间:2023-01-11 16:24:59
从命令行,使用 --testNamePattern
或 -t
标志:
From the command line, use the --testNamePattern
or -t
flag:
jest -t 'fix-order-test'
这只会运行与您提供的测试名称模式匹配的测试.它位于 Jest 文档中.
This will only run tests that match the test name pattern you provide. It's in the Jest documentation.
另一种方法是在监视模式下运行测试,jest --watch
,然后按 P 通过键入测试文件名或 过滤测试T 运行单个测试名称.
Another way is to run tests in watch mode, jest --watch
, and then press P to filter the tests by typing the test file name or T to run a single test name.
如果你在 describe
块中有一个 it
,你必须运行
If you have an it
inside of a describe
block, you have to run
jest -t '<describeString> <itString>'