2014-02-27 25 views
1

所以我有我可愛的測試系統都準備好了,但我碰到的一個問題,在我的CI服務器上運行它:出於某種原因灰燼測試是在抱怨運行循環,但只有同時PhantomJSEmberJS測試與噶 - runloop誤差PhantomJS但與鉻

運行下面是噶輸出:

Waiting for previous execution... 
PhantomJS 1.9.7 (Linux) DEBUG: 'DEBUG: -------------------------------' 
PhantomJS 1.9.7 (Linux) DEBUG: 'DEBUG: Ember  : 1.4.0' 
PhantomJS 1.9.7 (Linux) DEBUG: 'DEBUG: Ember Data : 1.0.0-beta.7+canary.b45e23ba' 
PhantomJS 1.9.7 (Linux) DEBUG: 'DEBUG: Handlebars : 1.0.0' 
PhantomJS 1.9.7 (Linux) DEBUG: 'DEBUG: jQuery  : 1.9.1' 
PhantomJS 1.9.7 (Linux) DEBUG: 'DEBUG: -------------------------------' 
Chrome 33.0.1750 (Mac OS X 10.9.1) DEBUG: 'DEBUG: -------------------------------' 
Chrome 33.0.1750 (Mac OS X 10.9.1) DEBUG: 'DEBUG: Ember  : 1.4.0' 
Chrome 33.0.1750 (Mac OS X 10.9.1) DEBUG: 'DEBUG: Ember Data : 1.0.0-beta.7+canary.b45e23ba' 
Chrome 33.0.1750 (Mac OS X 10.9.1) DEBUG: 'DEBUG: Handlebars : 1.0.0' 
Chrome 33.0.1750 (Mac OS X 10.9.1) DEBUG: 'DEBUG: jQuery  : 1.9.1' 
Chrome 33.0.1750 (Mac OS X 10.9.1) DEBUG: 'DEBUG: -------------------------------' 
Chrome 33.0.1750 (Mac OS X 10.9.1) DEBUG: 'DEBUG: For more advanced debugging, install the Ember Inspector from https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi' 
PhantomJS 1.9.7 (Linux) ERROR 
    Error: Assertion Failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in an Ember.run 
    at /apps/contentpartnerpages/ember/app/bower_components/ember/ember.js:73 
Chrome 33.0.1750 (Mac OS X 10.9.1) SLOW 0.743 secs: Chats Filter tests verify adding one chat to the store 
Chrome 33.0.1750 (Mac OS X 10.9.1) SLOW 0.649 secs: Chats Filter tests verify number of missed chats 
Chrome 33.0.1750 (Mac OS X 10.9.1) SLOW 0.763 secs: Chats Filter tests verify the sparklines update 
Chrome 33.0.1750 (Mac OS X 10.9.1) SLOW 0.657 secs: Chats Filter tests verify global filters apply to child controllers 
Chrome 33.0.1750 (Mac OS X 10.9.1) SLOW 0.783 secs: Chats Filter tests verify local filters work with global filters 
PhantomJS 1.9.7 (Linux): Executed 0 of 0 ERROR (0.642 secs/0 secs) 
Chrome 33.0.1750 (Mac OS X 10.9.1): Executed 6 of 6 SUCCESS (4.301 secs/3.966 secs) 

正如你可以看到他們在鉻清楚地工作!我不能認爲會有什麼不同,但如果有人能指出我的方向真的很棒。

+0

我剛纔問過類似的問題僅僅一個小時後,你的 - http://stackoverflow.com/questions/22084324/geb-tests-pass-with-chrome-fail-與幻影。我發現如果有AJAX或其他DOM更新,waitFor會有所幫助,但我不明白瀏覽器差異的原因。 – wrschneider

回答

1

很奇怪,這只是發生在鉻,但儘管如此,這個問題是最有可能是在測試中的一個,你有異步的問題。隔離並找到導致此問題的測試,然後查看它接觸的代碼的哪些部分。然後,你需要確保在該代碼(包括防火觀察員)集,創建,銷燬和Ajax調用被包裹在餘燼運行循環:

Ember.run(function(){ 
    // all call that results in asynchronous operations goes here 
}); 

一旦做到這一點,您的問題將最可能會消失!另外,在等待異步調用完成的異步調用之後,請確保使用具有「waitFor」或「andThen」函數(取決於測試框架)。讓我知道這是否有效。

來源:

http://discuss.emberjs.com/t/guide-asynchronous-side-effects-in-testing/2905

+0

所以,我已經通過所有的東西了,因爲我只是新的灰燼測試之前,我當我只是直接使用Qunit就那麼幾個人。 我現在要回過頭來看看,但是我得到的這條線是: PhantomJS 1.9.7(Linux):執行0或0錯誤(0.642秒/ 0秒) 它很早就失敗了它甚至試圖開始測試! –

+0

此錯誤可能發生在測試前發生的「before」語句中,但此時無法知道。你可以發佈一個jsfdidle來查看你的代碼嗎? – Jaime

+0

問題是我有一個$ .getJson()發生在實際應用程序本身之外,我只是沒有注意到它。即它不在我的任何初始函數中。結束使用Ember.run,它工作正常 –