2017-06-19 55 views
0

我實現了一個新的測試框架,用於基於Nightwatch.js的Nightwatch-Cucumber在node.js中進行自動化測試。所以,有時我使用node.js斷言來檢查一些值。我在框架中使用PageObject模式。我的問題是瀏覽器會話在斷言失敗後不會關閉,我不知道爲什麼,也不知道如何解決問題。關閉瀏覽器會話失敗斷言與夜校

這裏是我的StepDefinition:

const { 
    client 
} = require('nightwatch-cucumber'); 
const { 
    defineSupportCode 
} = require('cucumber'); 

const page = client.page.page(); 

defineSupportCode(({Given, When, Then}) => { 
    When(/^test$/,() => { 
    return page.test(); 
    }); 
}); 

這就是我的PageObject功能:

module.exports = { 
    elements: {}, 
    commands: [{ 
    test() { 
     //here the assertion failed and the browser session still exist and doen't close 
     this.assert.equal(false, true); 

     return this.api; 
    } 
    }] 
}; 

所以,我能做些什麼來實現它來關閉瀏覽器和部份測試會話?只有在node.js斷言失敗時纔會發生。

回答

相關問題