Why does SauceLabs say my QUnit test doesn't fire when it clearly passes?
We are trying to use SauceLabs to verify that our QUnit browser tests pass on popular combinations of devices and browsers ...
PASS test when we look at them in the browser: https://ordenado.herokuapp.com/
But somehow SauceLabs tells us they "couldn't" ...
See: https://saucelabs.com/tests/5b0f07813a7f4934bb44b07606ea2fd5
CURL command used
We used the following curl command for reference:
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"
}'
Also, is anyone else experiencing the following error:
" Sauce VMs Failed to Launch Browser or Device "
Visit: https://saucelabs.com/u/ordem for a complete list of tests. click on any of those that Sauce claims to "failed" and watch the video to see the tests pass!
Any insight is greatly appreciated!
source to share
You have to add some hooks to report qunit test results from SauceLabs.
article on how to get started with qunit. A repository is mentioned here with an example where a code snippet is provided:
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);
}
}
});
Add this code before your tests and results are reported correctly
source to share