2013-06-03 14 views

回答

0

爲了讓您的測試繼續運行,即使beforeEach()拋出錯誤,您也必須處理該錯誤。目前,beforeEach()拋出未處理的錯誤。

要處理這種錯誤的NodeJS,使用一個回調函數參數:

beforeEach(done) { 
    // your code here 

    // if there was an error 
    if (error !== null) { 
     // callback with a parameter, indicates failure 
     done(new Error('failed')); 
    } else { 
     // more code here 
     // callback without parameter, indicates success! 
     done(); 
    } 
}