Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting started with nightwatch.js

Can anyone provide me with a detailed explanation on how to setup nightwatch and start writing browser tests? I have searched for such information online and was unable to find it. The nightwatch.js website had good information about various nightwatch command line commands, but not about actually setting up a nightwatch project, which is what I am having trouble with.

Specifically, I do not have a good understanding of the various files that come with installation of nightwatch, and how I am supposed to use them.

like image 592
Raj Prabakhar Avatar asked Jun 19 '14 18:06

Raj Prabakhar


2 Answers

Step-by-Step Beginner's Tutorial

We needed an up-to-date, well-researched and maintained tutorial for Nightwatch for our team so we wrote one: https://github.com/dwyl/learn-nightwatch

Codeship Dependency Status devDependency Status contributions welcome

We (highly) recommend using a nightwatch.conf.js (.js) file for configuring Nightwatch because (unlike a .json file) it allows you leave in-line comments to your fellow developers (i.e avoid "WTF" moments by communicating) and to evolve your configuration with variables & functions as needed.

Also, we prefer to install Nightwatch (and its required dependencies) locally so it's clear to everyone exactly what is required to run the project and which versions we are using.

Using the selenium-download module will download the latest versions of Selenium Standalone Server and Chromedriver (both required to run a basic Nightwatch test) for your OS and means you will be up-and-running much faster.

Rather than including the whole tutorial here we invite you to Star/Fork it on GitHub: https://github.com/dwyl/learn-nightwatch#step-by-step-tutorial

Feedback / questions / updates / improvements are always welcome!

like image 74
nelsonic Avatar answered Sep 29 '22 12:09

nelsonic


You need basiclly two things:

  • The nightwatch.json file in the root of your project
  • And nightwatch installed (npm install -g nightwatch).

After that you use it on the command line as described in the documentation here and it will automatically grab your nightwatch.json file and run your tests based on the default test_setting.

I opened up an issue to add a nightwatch init command, so the setup of the nightwatch.json file is easier.

Further reading

  • How to setup nightwatch.json
  • Github Repository
like image 29
e382df99a7950919789725ceeec126 Avatar answered Sep 29 '22 10:09

e382df99a7950919789725ceeec126