如何跳过测试Nightwatch.js?
问题描述:
我现在使用nightwatch.js,mocha.js和selenium web driver进行验收测试。 我需要跳过一些测试,我该怎么做?如何跳过测试Nightwatch.js?
module.exports = {
"User logs in the WebPortal": function(browser) {
browser
.url(urlAdress)
.setValue('input#login', user.login)
.setValue('input#password', user.password)
.click('button.ui-button')
.waitForElementPresent('a[href="/logout"]', middleTimer)
.getText('a[href="/logout"] span', function(result) {
(result.value).should.be.exactly("logout")
})
.end()
},
"User logs out": function(browser) {
browser
.url(urlAdress)
.setValue('input#login', user.login)
.setValue('input#password', user.password)
.click('button.ui-button')
.waitForElementPresent('a[href="/logout"]', middleTimer)
.click('a[href="/logout"]')
.waitForElementPresent('button.ui-button', middleTimer)
.getText('button.ui-button', function(result) {
(result.value).should.be.exactly("Login")
})
.end()
}
}
那么,如何跳过一个或多个测试呢? 谢谢你的答案。
答
所以,我找到了解决方案,通过添加mocha.js包装到我的测试。 摩卡拥有跳过测试,套房,自己的功能...
答
不使用Mocha
或Grunt
。我能够使用跳过:
-
使用
'@disabled': true,
这样after module.exports = { '@disabled': true,
就会将跳过里面的一切
module.exports = {
和打印跳过声明控制台
-
跳过特定测试:
在你
.js
文件,如果你有这么多的考验,你想跳过特定测试, 使用''+
前缀测试function
之前在您的测试,如:'Test 1': '' + function (client) { }, 'Test 2': '' + function (client) { }, 'Test 3': function (client) { }
前两个测试将被跳过和第三将获得执行。不会打印跳过声明。
答
你可以用感叹号!
或一些其他有效的字符只是前缀function关键字:通过这种方式标明
"User logs in the WebPortal": !function(browser) {
browser
.url(urlAdress)
...
.end()
},
测试将不会被执行。
您是否想要跳过使用命令行参数的测试,或者向测试用例添加一些代码? –
@Jens Wegar,谢谢你,但我通过在我的测试中加入mocha.js包装找到了解决方案! – Arsenowitch
酷!如果您可以添加解决方案作为对此问题的答案并接受它,那么这样做会很好,所以它会从未回答的问题列表中删除;) –