2014-12-22 216 views
0

我只是学习使用摩卡和Saucelabs,所以我很可能在这里做出noob错误。摩卡测试超时Saucelabs

我的测试在我的浏览器中运行良好。他们在Saucelabs的手动会议中运行良好。但是当我使用REST界面运行它们时,它们会超时。看着屏幕截图,我可以看到测试都成功了。酱只是没有注意到。

我发送的命令到REST接口这样的:

卷曲https://saucelabs.com/rest/v1/gbthr/js-tests \ -X POST \ -u gbthr:00000000-0000-0000-0000-000000000000 \ -H“内容 - 类型:应用程序/ json'\ --data'{platform}:[[“Linux”,“googlechrome”,“”]], “url”:“http://gbserver3.cs.unc.edu/theme/tests/testStore.html”, “framework”:“mocha”}'

这些0000的替换为我的ID。

在测试中我需要做些额外的步骤来通知苏打水吗?

回答

0

,我发现这里的答案:https://github.com/axemclion/grunt-saucelabs

在测试结束时,你的结果添加到window.mochaResults。

var runner = mocha.run(); 

var failedTests = []; 
runner.on('end', function(){ 
    window.mochaResults = runner.stats; 
    window.mochaResults.reports = failedTests; 
}); 

runner.on('fail', logFailure); 

function logFailure(test, err){ 

    var flattenTitles = function(test){ 
    var titles = []; 
    while (test.parent.title){ 
     titles.push(test.parent.title); 
     test = test.parent; 
    } 
    return titles.reverse(); 
    }; 

    failedTests.push({name: test.title, result: false, message: err.message, stack: err.stack, titles: flattenTitles(test) }); 
};