What's New in v2

Nightwatch 2.0 contains a wide range of new features and improvements for writing and running tests as well as full cross-browser testing support for W3C WebDriver compliant browsers.

The underlying architecture for communicating with the browsers has been completely reworked in order to build on top of the official Selenium-Webdriver Node.js library. This means that Nightwatch is now much better equipped for cross-browser integration and DOM element handling, and overall is able to deliver more stable and faster tests.

Since Nightwatch 2 builds on top of Selenium now, it is never behind any new WebDriver API.

Nightwatch 2.0.0-beta.1

New Features:

  • New user actions API

    Nightwatch 2 brings support for working with the newer Actions API from Selenium WebDriver for performing complex user gestures.

  • Integrated test runner for CucumberJS

    Nightwatch 2 brings integrated support for using Cucumber.js directly as an alternative test runner. No other plugins are necessary, other than the Cucumber library itself (version 7.3 or higher).

  • Improved Mocha test runner

    The integrated Mocha runner has been upgraded to use Mocha v9 and also the implementation has been updated to match most of the features that Nightwatch offers in its own default test runner, like the ability to use tags or global test hooks. You can now also use reporters like Mochawesome.

  • Support for Chrome DevTools Protocol

    When using ChromeDriver or EdgeDriver it is now possible to execute commands via the Chrome DevTools protocol.

  • New .ensure assertions API

    The new .ensure API is a direct mapping to the existing until module from Selenium and provides an extra level of flexibility for performing assertions in tests.

  • New programmatic API

    A brand new programmatic api is available in Nightwatch 2, which makes it very easy to use Nightwatch externally, either by creating your custom runner or by using external test runners like Jest, Mocha, or Ava.

  • New element() global and support for using WebElements

    The newly added element() global object adds to Nightwatch 2 the commands from the Selenium WebElement instance.

New Commands:

Improvements:

  • specify page commands as an ES6 class (details);
  • added enable_fail_fast setting and --fail-fast cli argument to abort the test runner after a failed test suite;
  • added support to use the config file as Promise;
  • added support to use glob patterns in config for src_folders, page_object_path, custom_commands_path, custom_assertion_path options;
  • browser is now available as a global; other globals: element(), by(), expect(), Keys
  • added support to use Selenium Capabilities objects in Nightwatch config

Breaking changes:

We have tried to keep the breaking changes to a minimum, however some changes were unavoidable. See the migrate to v2 guide for details.

From the Blog:

Improve this article