testing - 是否可以在 Karma 中使用 QUnit 运行单个测试?

标签 testing qunit karma-runner

Jasmine有iit()ddescribe,Mocha有it.onlydescribe.only,但我看不出有什么方法可以让 QUnit 专注于运行单个测试。

QUnit UI 允许您运行单个测试,但我看不出如何让它在 Karma 中运行,因为它不显示 QUnit UI。

最佳答案

这是我的解决方案。它对我来说很好用,但是 YMMV。

here 下载 qunit-karma-setup.js, qunit-karma-launch.js

然后,在你的 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() 函数分别仅运行选定的模块或测试。

关于testing - 是否可以在 Karma 中使用 QUnit 运行单个测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18975998/

相关文章:

c - C 解释器的测试用例

ruby-on-rails - 避免在 RSpec 中重新创建主题

unit-testing - 有没有办法延迟 QUnit 测试套件的启动?

javascript - 使用 gulp 将 karma 测试拆分为可运行 block 的最佳方法是什么?

使用订阅者 channel 测试 Spring-Integration

javascript - 编写 "unit testable"jQuery 代码?

javascript - JS 单元测试无需将整个 HTML 复制到单元测试中?

angularjs - 如何在链接阶段测试指令?

git - 使用 grunt 运行 Angular.js 时如何修复错误 "Please set env variable CHROME_BIN"

python - 控制顺序测试在 Selenium 中运行