且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Jest运行单个测试?

更新时间:2023-01-11 16:33:29

从命令行使用--testNamePattern-t标志

jest -t 'fix-order-test'

这只会运行与您提供的测试名称模式匹配的测试.在笑话文档中.

This will only run tests that match the test name pattern you provide. It's in the Jest docs.

另一种方法是在监视模式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.