问题描述
Jasmine具有iit()
和ddescribe
,而Mocha具有it.only
和describe.only
,但是我看不到任何方法可以使QUnit专注于运行单个测试.
Jasmine has iit()
and ddescribe
, and Mocha has it.only
and describe.only
, but I can't see any way to get QUnit to focus on running a single test.
QUnit UI允许您运行一个测试,但是我看不到如何使其在Karma中工作,因为它不显示QUnit UI.
The QUnit UI allows you to run a single test, but I can't see how to get this to work inside Karma, because it doesn't display the QUnit UI.
推荐答案
这是我的解决方案.对我来说很好,但是YMMV.
Here is my solution. It works fine for me, but YMMV.
从此处下载qunit-karma-setup.js,qunit-karma-launch.js.
Download qunit-karma-setup.js, qunit-karma-launch.js from here
然后,在您的Gruntfile中:
Then, in your Gruntfile:
config.set({
frameworks: ['qunit'],
files: [
'your-app-files-here/**/*.js',
'qunit-karma-setup.js',
'your-tests-here/**/*.js',
'qunit-karma-launch.js'
]
});
现在,您可以使用omodule(),otest()和oasyncTest()函数分别仅运行所选的模块或测试.
Now, you can use omodule(), otest(), oasyncTest() functions to run only the selected modules or tests respectively.
这篇关于是否可以在Karma中使用QUnit运行单个测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!