gpt4 book ai didi

javascript - 如何跳过测试 Nightwatch.js?

转载 作者:数据小太阳 更新时间:2023-10-29 05:57:21 27 4
gpt4 key购买 nike

我目前使用 nightwatch.js、mocha.js 和 selenium 网络驱动程序进行验收测试。我需要跳过一些测试,我该怎么做?

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()
}
}

那么,如何跳过一个或多个测试呢?谢谢你的回答。

最佳答案

不使用 MochaGrunt。我可以跳过使用:

  1. 像这样使用 '@disabled': true,

    after module.exports = {
    '@disabled': true,

    它将跳过 module.exports = {

    中的所有内容

    并在控制台打印skip语句

  2. 跳过特定测试:

    在你的 .js 文件中,如果你有太多的测试并且你想跳过特定的测试,在测试中使用 ''+ 作为测试 function 之前的前缀,如下所示:

    'Test 1': '' + function (client) {
    },
    'Test 2': '' + function (client) {
    },
    'Test 3': function (client) {
    }

    前两个测试将被跳过,第三个将被执行。不会打印跳过语句。

关于javascript - 如何跳过测试 Nightwatch.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34905254/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com