Nightwatch.js review - a JS testing solution

Overview of Nightwatch.js - Node.js testing solution for browser based apps and websites
04 August 2017   1546

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.

Features:

  • Clean syntax
    • Simple but powerful syntax which enables you to write tests very quickly, using only Javascript (Node.js) and CSS or Xpath selectors.
  • 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.

AngularJS to Angular Migration Tools to be Released

New tools are called ngMigration Assistant and ngMigration Forum
17 August 2018   207

The JS-development team AngularJS has released two customers' "helper" - ngMigration Assistant and Forum. The tools show which migration from AngularJS to Angular is correct, how to simplify the process as much as possible and avoid mistakes.

ngMigration Assistant is a command-line tool that analyzes any AngularJS application, regardless of size, and recommends an optimal migration path. It provides statistics on the complexity, size, and patterns of an app. Based on this data, the program offers a list of clear recommendations that simplify the transition from AngularJS to Angular, taking into account the size and complexity of the code.

You can find an example of using the ngMigration Assistant for the AngularJS phone catalog application below. Using the ngma command, registered in the directory, analysis is performed and recommendations are written.

Displaying ngMigration Assitant statistics
Displaying ngMigration Assitant statistics

Initially, the tool shows statistics of the available data, and after - the stages of preparation for migration to Angular.

NgMigration Assitant Recommendations
NgMigration Assitant Recommendations

The new ngMigration Forum collects up-to-date information on migration paths and tools that provide the transition from AngularJS to Angular. ngMigration Forum is a place for sharing experiences, solving problems and asking questions.

The last update of Angular 6.1 was released in late July 2018. In Angular, support for TypeScript 2.8 and 2.9 was added, as well as the ability to configure the router to store and restore the scrolling position