Nightwatch.js is an integrated framework for performing automated end-to-end testing on web applications and websites, across all major browsers. It is written in Node.js and uses the W3C WebDriver API to interact with various browsers.

It is a complete solution for end-to-end and cross-browser testing. It aims to simplify the process of writing and running various types of tests, including:

  • end-to-end tests on all major web browsers
  • unit tests of Node.js services
  • integration tests of HTTP APIs

Nightwatch was created in 2014 in Amsterdam, The Netherlands, and the name was inspired by the famous painting The Night Watch by Dutch 17th century artist Rembrandt van Rijn. The masterpiece is prominently displayed in the Rijksmuseum, in Amsterdam. Read more about how Nightwatch was created here.

Why choose Nightwatch?

  • Clean Syntax

    Simple but powerful syntax which enables you to write tests very quickly, using Javascript (Node.js) and CSS or Xpath selectors. Typescript is supported as well.

  • Integrated Test Runner

    Built-in command-line test runner which runs the tests either sequentially or in parallel, with retries and implicit waits. Also supports grouping of test suites and tags.

  • Cloud Testing Support

    Works with BrowserStack out of the box. Other cloud testing providers, such as SauceLabs or LambdaTest are easy to add as well.

  • Page Objects Support

    Fluent and easy to work with, has Page Object Model support to better organise elements and sections, and also supports both CSS or Xpath selectors.

  • Plugin API

    Flexible command and assertion framework, which makes it easy to implement your own plugins and extend the built-in commands and assertions APIs.

Architecture overview

Nightwatch is distributed as an easy to use CLI tool and has built-in support for all major browsers: Chrome, Firefox, Safari, and Edge.

Nightwatch performs the browser automation by taking advantage of the industry standard protocol WebDriver, which is defined as a W3C standard specification.

Theory of Operation

Nightwatch is sometimes inaccurately described as a "Selenium binding" library. While it's true that Nightwatch can be (and is often) used together with the Selenium Server it's important to remember that Nightwatch is a complete testing solution which contains a built-in CLI test runner, an extendable command and assertion library, and support for page object model.

Improve this article