如何使用Karma / Jasmine运行单个测试文件? [英] How to run a single test file with Karma/Jasmine?
问题描述
我正在使用Karma和Jasmine来测试我的Angular JS代码。我设法使用Karma在我的项目中运行所有测试,但如果我尝试只运行一个文件,我会收到以下错误: ReferenceError:describe未定义
。是否可以只运行一个测试文件,如果是,那么如何?
I'm using Karma and Jasmine for testing my Angular JS code. I managed to run all the tests in my project using Karma, but if I try to run just a single file I'm getting the following error: ReferenceError: describe is not defined
. Is it possible to run just a single test file and if yes then how?
P.S。我正在使用Intellij IDEA。
P.S. I'm using Intellij IDEA.
推荐答案
虽然它不理想,但您可以替换 describe
(和 it
) fdescribe
(和 fit
)所以只会执行那些测试
Although it's not ideal, you can replace describe
(and it
) with fdescribe
(and fit
) so only those tests will be executed
另一方面, xdescribe
/ xit
从你的套房中排除测试
On the other hand, xdescribe
/ xit
excludes the tests from your suite
如果你使用Gulp,你可以结合gulp-karma& yargs传递一个模式作为参数。
If you use Gulp, you can combine gulp-karma & yargs to pass in a pattern as argument.
source: https:// stackoverflow.com/a/27696472/1782659
这篇关于如何使用Karma / Jasmine运行单个测试文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!