End to End testing of React applications with Nightwatch
In the mid of 2015 our front-end team took the challenge of rebuilding the entire Dashboard from scratch. In a matter of three months we built a new version using the React library. Since it was hard to keep up with writing unit tests at such demanding pace we decided that end-to-end (e2e) will be our go-to test strategy.
The most obvious choice for e2e tests is Selenium but there are many language bindings and frameworks to choose from. Eventually we settled on Nightwatch.js.
We wanted to share our experience, thus we have created this repository holding all our blog posts with code examples.
Every part of it will be organized in a separate folder beginning with part-
and number representing the blog posts number in the series.
Part Title | Folder |
---|---|
End to End testing of React apps with Nightwatch | Part 1 |
Before(), after() hooks and custom commands in Nightwatch | Part 2 |
Data Driven Testing at Syncano | Part 3 |
First thing you need to do is to install Node.js if you don’t yet have it. You can find the installation instructions on the Node.js project page. Once you have node installed, you can take advantage of it’s package manager called npm
.
You will also need
:
As they are all required for Selenium
and Nightwatch
to work properly.
Before you will be able to run any tests you should install proper part
in it's folder. To do so just follow examples below, where X
is post number/directory.
$ cd part-X/
$ npm install
$ npm run e2e-setup
Now you have installed all dependancies using npm
and executed node
script that installs selenium.
If you have any questions, or just want to say hi, drop us a line at support@syncano.com.