Introducing Nightwatch.js

Nightwatch.js is a testing solution that lets you use JavaScript to write browser-based, end-to-end tests. Nightwatch can also be used for writing Node.js unit tests. Nightwatch is written in Node.js and using the W3C WebDriver API (formerly Selenium WebDriver).

Installation:

  • • Go to http://nodejs.org/ and install nodejs in the new folder, ensure you include the npm tool in your installation
  • • npm is installed with Node.js, just run this command in terminal to check the version of npm: npm -v. If this is not latest version just type npm install npm@latest -g
  • • Install Nightwatch by typing npm install -g nightwatch . -g option will make sure you install Nightwatch globally in your system which I found useful for my purposes.
  • • Get Selenium Server: download “selenium-server-standalone-{latest version}.jar” from http://selenium-release.storage.googleapis.com/index.html . Selenium server can run automatically if is on the same machine where Nightwatch is running, this will be explained in the next post. Selenium server can also run manually. In the directory where the selenium jar file just type java -jar selenium-server-standalone-{latest version}.jar in the console.
  • • Get Chromedriver: ChromeDriver is a standalone server which implements the W3C WebDriver wire protocol for Chromium. To get the executable, head over to the downloads section, and place it to the one folder. Setting the path to this folder will be covered when we configure Nightwatch. Note, each browser needs own driver, we will currently use only Chrome.

Nightwatch is installed successfully and before running some tests we need to configure it and end-to-end testing can start. Nightwatch can be installed in few different ways, found this one as easiest.

Configuration of Nightwatch will be covered in my next post.

Similar Posts from the author: