如何仅在业力中运行某些测试? [英] How do I run only certain tests in karma?
问题描述
我已经正确设置了业力配置,配置文件在后台运行,非常好.我更改并保存文件后,它将重新运行测试....所有750个单元测试.我希望能够只运行几个.除了手动修改配置文件或注释掉许多文件中的数百个测试之外,还有什么简单的方法可以做到这一点?
I have karma config set up correctly, config file, running in the background, just great. As soon as I change and save a file, it reruns the tests.... all 750 of the unit tests. I want to be able to run just a few. Short of manually hacking the config file or commenting out hundreds of tests across many files, is there any easy way to do it?
例如当使用说摩卡运行命令行服务器测试时,我只使用regexp:mocha -g 'only tests that I want'
.使调试和快速检查变得更加容易.
E.g. when running command line server tests using say mocha, I just use regexp: mocha -g 'only tests that I want'
. Makes it much easier to debug and quickly check.
推荐答案
所以现在我觉得很愚蠢. mocha支持非常狭窄的regexp匹配.
So now I feel foolish. mocha supports a very narrow version of regexp matching.
这将运行所有测试
describe('all tests',function(){
describe('first tests',function(){
});
describe('second tests',function(){
});
});
这仅运行首次测试"
describe('all tests',function(){
describe.only('first tests',function(){
});
describe('second tests',function(){
});
});
您也可以执行it.only()
我应该已经注意到了.叹气.
I should have noticed that. Sigh.
这篇关于如何仅在业力中运行某些测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!