I use nightwatch.js, mocha.js and selenium web driver for acceptance testing for now. And I need to skip some tests, how I can do it?
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()
}
}
So, how to skip one or more tests? Thank you for answers.
You can also execute a single test with the --test flag, e.g. Show activity on this post. just add it to your test case: module.
Use the command: npm install --save-dev nightwatch chromedriver. 1.
To execute tests in multiple browsers, you need to add the desired capabilities of the browsers and Test_worker configurations in nightwatch. json file. For example if you want to execute tests in three browsers parallely - Chrome, Firefox and Opera, your nightwatch. json should something like this.
Without using Mocha
or Grunt
. I am able to skip using:
Use '@disabled': true,
like this
after module.exports = {
'@disabled': true,
it will will skip everything inside module.exports = {
and print skip statement in console
Skip specific tests:
In your .js
file if you have so many tests and you want to skip specific test,
use ''+
as prefix before test function
in your test, like this:
'Test 1': '' + function (client) {
},
'Test 2': '' + function (client) {
},
'Test 3': function (client) {
}
first two tests will be skipped and third will get executed. No skip statement will be printed.
You can just prefix function keyword with exclamation !
or some other valid character:
"User logs in the WebPortal": !function(browser) {
browser
.url(urlAdress)
...
.end()
},
Tests marked by this way will not executed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With