2014-12-22 215 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) }); 
};