Testing is one of the most important parts of software development. Without properly made test, few lines of code can crash down giant app or a website.
Nightwatch.js is convenient and an easy to use Node.js based End-to-End (E2E) testing solution for browser based apps and websites. It uses the powerful W3C WebDriver API to perform commands and assertions on DOM elements. With it, you can write End-to-End tests in Node.js quickly and effortlessly.
- Clean syntax
- Selenium server
- Controls the Selenium standalone server automatically in a separate child process; can be disabled if Selenium runs on another host.
- CSS & Xpath support
- Either CSS or Xpath selectors can be used to locate and verify elements on the page or execute commands.
- Easy to extend
- Flexible command and assertion framework which makes it easy to extend to implement your application specific commands and assertions.
- Built-in test runner
- Built-in command-line test runner which can run the tests either sequentially or in parallel, together, by group, tags or single. Gruntsupport is built-in.
- Cloud services support
- Works with cloud testing providers, such as SauceLabs and BrowserStack.
- Continous integration support
- JUnit XML reporting is built-in so you can integrate your tests in your build process with systems such as Teamcity, Jenkins, Hudson etc.
WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform and a restful HTTP api as a way for web browsers to be remotely controlled.
Nightwatch works by communicating over a restful HTTP api with a WebDriver server (typically the Selenium server). The restful API protocol is defined by the W3C WebDriver API. See below for an example workflow for browser initialization.
Most of the times, Nightwatch needs to send at least 2 requests to the WebDriver server in order to perform a command or assertion, the first one being the request to locate an element given a CSS selector (or Xpath expression) and the next to perform the actual command/assertion on the given element.
Learn more about Nightwatch.js.