2016-02-12 23 views
0

我使用Nightwatch,Mocha和Should.js進行測試。 而在某些情況下,我會檢查元素的文本值。 我的問題是 - 如何使測試狀態 - 「失敗」,當文本值不等於預期值?如何返回測試狀態 - should.js「失敗」?

it("Test should return 'fail' status", function(client) { 
 
    client 
 
     .url(urlAddress) 
 
     .waitForElementPresent("h1", config.middleTimer) 
 
     .getText("h1", function(result) { 
 
     result.value.should.be.exactly("Expected text!!!"); 
 
     }) 
 
     .end() 
 
    });

回答

0

我找到了解決辦法:

.getText("div.ui-notifications .error", function (result) { 
 
     this.assert.equal(result.value, "Expected value"); 
 
     })

這種結構將改變測試狀態爲 「失敗」! 「這個」等於摩卡賽跑者。

相關問題