nightwatch-framework
This package provides Nightwatch integration with Velocity and Meteor. It's recommended to also use velocity:nightwatch-reporter package. The primary responsibilities of this package include:
a) integrating the clinical:nightwatch package which provides Selenium
b) installing nightwatch
c) parsing XML output files produced by Nightwatch
d) launching the clinical:nightwatch bridge to the Selenium server
e) keeping velocity dependencies out of Nightwatch, so it can run stand-alone
f) integrating with the `meteor --test`` command
g) providing Travis CI integration
===============================
Architecture
View the Prezi on Nightwatch/Selenium Architecture
===============================
Recommended Version
METEOR 1.0.4
===============================
Known Bugs
There is a known bug with Meteor 1.0.5 so please install 1.0.4 instead until we can get things fixed.
===============================
Installation
Simply add the package to your application. It will load everything else in.
meteor add velocity:nightwatch-framework # you may also want to use the Nightwatch HTML Reporter meteor add velocity:nightwatch-reporter
===============================
Configure the Filesystem
You'll need to begin by creating the following files and directories in your /tests directory. For now, the contents of global.json
can be an empty json object {}
.
# create the following files /tests/nightwatch/globals.json /tests/nightwatch/logs /tests/nightwatch/commands /tests/nightwatch/assertions /tests/nightwatch/walkthroughs # and be sure to set lax permissions so nightwatch can manage files terminal-a$ chmod -R 777 tests/nightwatch
===============================
Usage - Command Line
The default usage is via command line, and requires that the VELOCITY_CI
environment variable be set, which puts Meteor and Velocity into Continuous Integration mode. Nightwatch basically always runs in Continuous Integration mode.
terminal$ VELOCITY_CI=true meteor --test
===============================
Write Your First Acceptance Test
Check out this super simple syntax for writing acceptance tests. All you need to do is copy the following code into a file in the /tests
directory, and Nightwatch will parse it accordingly.
1// tests/nightwatch/walkthrough/helloworld.js 2 3module.exports = { 4 "Hello World" : function (client) { 5 client 6 .url("http://127.0.0.1:3000") 7 .waitForElementVisible("body", 1000) 8 .assert.title("Hello World") 9 .end(); 10 } 11}; 12 13// tests/google.js 14module.exports = { 15 tags: ["foo"], 16 "Demo Test Google" : function (client) { 17 client 18 .url("http://www.google.com") 19 .waitForElementVisible("body", 1000) 20 .assert.title("Google") 21 .assert.visible("input[type=text]") 22 .setValue("input[type=text]", "nightwatch") 23 .waitForElementVisible("button[name=btnG]", 1000) 24 .click("button[name=btnG]") 25 .pause(1000) 26 .assert.containsText("#main", "The Night Watch") 27 .end(); 28 } 29}; 30 31#### Resetting the Database For New Runs 32You may notice that your database has gotten out of sync with your tests. Don't worry, as that's normal. The easy thing to do is just reset your database. But you'll eventually need to write your tests so they don't destructively modify your database, or you'll need to create tearUp and tearDown methods, or set up a testing database, or any number of other activities to manage your test data. 33 34````sh 35terminal-a$ meteor reset
Advanced Topics - Custom Commands, Assertions, and Logs
Custom Commands
Using Globals.js to Define Test Data
File Upload Dialog
Download File Assertion
Testing Minimongo and Browser Console with execute()
Code Injection using execute()
Connecting to SauceLabs
===============================
Licensing
MIT License. Use as you wish, including for commercial purposes.