Skip to content

Instantly share code, notes, and snippets.

@gsypolt gsypolt/asserts.txt
Last active Jul 12, 2018

Embed
What would you like to do?
blog - why using nightwatch is quick and effortlessly
'use strict';
module.exports = {
'@tags' : ['testName','typeOfTest']
//before block is optional
'Name of your test' : function(browser) {
// your Actual test steps are included in this section
browser
.url('Specify your test URL here')
.click('Element locator')
.assert('user action')
},
afterEach : function(browser){
// after block executes after each test run
browser
.customSauceEnd() //custom command used to finish the test if running in Sauce
.end();
done();
}
};
'use strict';
module.exports = {
before : function(browser){
//before block executes before each test run
},
'Name of your test' : function(browser) {
// your Actual test steps are included in this section
},
afterEach : function(browser){
// after block executes after each test run
}
};
exports.command = function(result) {
var SauceLabs = require("saucelabs");
var saucelabs = new SauceLabs({
username: process.env.SAUCE_USERNAME,
password: process.env.SAUCE_ACCESS_KEY
});
var sessionid = this.capabilities['webdriver.remote.sessionid'];
var jobName = this.currentTest.name;
saucelabs.updateJob(sessionid, {
passed: this.currentTest.results.failed === 0,
name: jobName
}, function() {});
console.log("SauceOnDemandSessionID=" + sessionid + " job-name=" + jobName);
this.end();
};
'use strict';
module.exports = {
'@tags' : ['testName','typeOfTest']
//before block is optional
'Name of your test' : function(browser) {
// your Actual test steps are included in this section
browser
//GIVEN the purpose of the test
.url('Specify your test URL here')
//WHEN the user action is performed
.click('Element locator')
//THEN assert the result
.assert('user action')
},
afterEach : function(browser){
// after block executes after each test run
browser
.customSauceEnd() //custom command used to finish the test if running in Sauce
.end();
done();
}
};
"src_folders" : ["./tests"],
"output_folder" : "./reports",
"custom_commands_path" : "./custom_commands",
"page_objects_path" : "./components",
"custom_assertions_path" : "",
"globals_path" : "",
"live_output" : false,
"parallel_process_delay" : 10,
"disable_colors": false,
"test_workers": {
"enabled": true,
"workers": 10
},
"selenium" : {
"start_process" : true,
"server_path" : "./node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.6.0.jar",
"log_path" : "",
"port" : 4444,
"cli_args" : {
"webdriver.gecko.driver" : "./node_modules/geckodriver/bin/geckodriver",
"webdriver.chrome.driver" : "./node_modules/chromedriver/bin/chromedriver",
"webdriver.ie.driver" : "",
"webdriver.firefox.profile" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "https://please-change-me.com",
"selenium_host" : "ondemand.saucelabs.com",
"selenium_port" : 4444,
"username" : "${SAUCE_USERNAME}",
"access_key" : "${SAUCE_ACCESS_KEY}",
"use_ssl" : false,
"silent" : true,
"output" : true,
"screenshots" : {
"enabled" : false,
"on_failure" : true,
"path" : "./screenshots"
},
"desiredCapabilities": {
"name" : "nightwatch-skeleton-lab",
"tags" : "nightwatch-skeleton",
"javascriptEnabled": true,
"acceptSslCerts": true
},
"globals" : {
"propertyData" : {
"goDirectURL":"${SITE_NAME}/go/directly/",
"environment":"default"
}
},
"selenium" : {
"start_process" : false
}
},
"sauce-android" : {
"desiredCapabilities": {
"name" : "Nightwatch - Mobile Web Android",
"appiumVersion" : "1.6.5",
"platformName" : "Android",
"platformVersion" : "7.0",
"deviceName" : "Android GoogleAPI Emulator",
"browserName" : "chrome"
},
"globals" : {
"propertyData" : {
"environment":"android-7"
}
}
},
"local-chrome" : {
"desiredCapabilities": {
"name" : "Nightwatch - local-chrome",
"browserName" : "chrome"
},
"globals" : {
"propertyData" : {
"environment":"local-chrome"
}
},
"selenium_host" : "localhost",
"selenium" : {
"start_process" : true
}
},
"sauce-osx-chrome" : {
"desiredCapabilities": {
"name" : "Nightwatch Skeleton - osx-chrome",
"platform" : "macOS 10.12",
"browserName" : "chrome",
"version": "61"
},
"globals" : {
"propertyData" : {
"environment":"os_x_10_12-chrome61"
}
}
},
nightwatch-skeleton/
|-- custom_commands/
|-- ci/
|-- functional-test.Jenkinsfile
|-- tests/
|-- functional-tests/
|-- visual-tests/
|-- nightwatch.json
|-- package.json
|-- README.md
|-- .gitignore
'use strict';
module.exports = {
'@tags' : ['testName','typeOfTest']
//before block is optional
'Name of your test' : function(browser) {
// your Actual test steps are included in this section
browser
//GIVEN the purpose of the test
.url('Specify your test URL here')
//WHEN the user action is performed
.perform(function(){
//User Action - 1
browser.click('Element locator')
})
.perform(function(){
//User Action - 2
browser.click('Element locator')
})
//THEN assert the result
.assert('user action')
},
afterEach : function(browser){
// after block executes after each test run
browser
.customSauceEnd() //custom command used to finish the test if running in Sauce
.end();
done();
}
};
'use strict';
module.exports = {
'@tags' : ['testName','typeOfTest']
before : function(browser){
//before block executes before each test run
},
'Name of your test' : function(browser) {
// your Actual test steps are included in this section
},
afterEach : function(browser){
// after block executes after each test run
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.