我想在jest.runCLI()
中使用gulp
来执行仅更改过的测试。
我该怎么做?
如何使用jest.runCLI()
运行一次测试?
答案 0 :(得分:8)
Jest has a CLI option to run only changed files (based on the git repository status).
The command line jest --onlyChanged
becomes programmatically:
jest.runCLI({'onlyChanged': true}, __dirname, function (success) {...});
Using the terminal, jest uses non-hyphenated options to specified filenames:
jest test1
runs only test1.jsjest test1 test2
runs test1.js and test2.jsjest-cli uses optimist to parse options and non-hyphenated option are mapped to the underscore option (_
):
jest.runCLI({'_': ['test1']}, __dirname, function (success) {...});
runs only test1.jsjest.runCLI({'_': ['test1', 'test2']}, __dirname, function (success) {...});
runs test1.js and test2.js