为什么SauceLabs明确表示我的QUnit测试失败?

时间:2015-05-12 07:32:48

标签: javascript unit-testing testing qunit saucelabs

我们正在尝试使用 SauceLabs 来验证我们基于浏览器的 QUnit 测试是否正在通过热门设备/浏览器组合...

我们在浏览器中查看测试 PASS https://ordenado.herokuapp.com/

但由于某种原因,SauceLabs告诉我们他们“失败了”......

saucelabs-ordem-test-is-clearly-passing

请参阅:https://saucelabs.com/tests/5b0f07813a7f4934bb44b07606ea2fd5

使用cURL命令

作为参考,我们使用了以下curl命令:

curl https://saucelabs.com/rest/v1/ordem/js-tests \
-X POST \
-u ordem:SECRET_KEY \
-H 'Content-Type: application/json' \
--data '{
    "platforms": [
      ["Windows 8.1", "internet explorer", "11"],
      ["Windows 8", "internet explorer", "10"],
      ["Windows 8.1", "firefox", "beta"],
      ["Windows 8", "firefox", "37"],
      ["Windows 7", "firefox", "32"],
      ["OS X 10.8", "safari", "6"],
      ["OS X 10.8", "chrome", "37"],
      ["Linux", "chrome", "30"],
      ["Linux", "firefox", "dev"],
      ["OS X 10.10","iphone", "7.0"],
      ["OS X 10.10","iphone", "8.2"],
      ["OS X 10.10","ipad", "7.0"],
      ["OS X 10.10","ipad", "8.2"]
    ],
    "url": "https://qunit.herokuapp.com/test/test.html?coverage=true",
    "framework": "qunit",
    "name":"ordem",
    "public": "public",
    "build": "build-007"
}'

此外,是否有其他人遇到过以下错误:

  

Sauce VM无法启动浏览器或设备

saucelabs-vm-failed

访问:https://saucelabs.com/u/ordem以获取完整的测试列表。 点击Sauce声称“失败”的任何一个并观看视频以查看测试通过!

saucelabs-ordem-test-summary-fails

非常感谢任何见解!

1 个答案:

答案 0 :(得分:1)

你应该添加几个钩子来报告来自SauceLabs的qunit测试结果。

an article如何开始使用qunit。提到repository with example以下是代码段:

var log = [];
QUnit.done = function (test_results) {
  var tests = log.map(function(details){
    return {
      name: details.name,
      result: details.result,
      expected: details.expected,
      actual: details.actual,
      source: details.source
    }
  });
  test_results.tests = tests;

  // delaying results a bit cause in real-world
  // scenario you won't get them immediately
  setTimeout(function () { window.global_test_results = test_results; }, 2000);
};
QUnit.testStart(function(testDetails){
  QUnit.log = function(details){
    if (!details.result) {
     details.name = testDetails.name;
     log.push(details);
    }
 }
});

在测试之前添加此代码,并正确报告结果