How We As a Team Chose a Testing Framework – Christine Zierold

What is Nightwatch.js

Nightwatch.js is an END to END Testing framework based on Node.js. It uses the WebDriver API from Selenium.
These are some of the features from this framework:

  • Using Selenium Server
  • CSS & XPath support
  • Easy to extend through other Node.js packages
  • Cloud service support as such as SauceLabs and BrowserStack
  • Built-in JUnit XML reports supporting continuous integration systems

WebDriverAPI - Nightwatch

Source: http://nightwatchjs.org/gettingstarted

The framework is well documented. It has a detailed ‘getting started’ guide to setup your first project and also an API Reference.

Why we chose it

In my last project, my team and I were building a frontend based on REACT. REACT is a javascript library for building user interfaces. The frontend should connect to a database via a REST API. The goal was to make it easier to enter data and also to have a manageable dashboard for all the data.

DBandAPI - NIghtwatch

Source: https://www.mongodb.com/blog/post/the-modern-application-stack-part-5-using-reactjs-es6-and-jsx-to-build-a-ui-the-rise-of-mern

In this team, we decided together to try the whole-team approach for a scrum team. That means everybody has equal responsibilities and try to work on everything but, surely, everybody wears a special hat for their specialties. So I coded primarily the UI Tests but I also programmed some smaller UI components or created Unit tests to get an even better code coverage (>90%). For me, the positive thing of this approach was that any of the team members could be sick or on vacation and still everything would go on. If a test would be red all of us were able to look into the log and check if there is a problem or if this was a hiccup of the system or network.

We chose Nightwatch.js because I wanted to lower the first barriers for the members of my team to also program UI Tests. I thought when I choose a framework in the same programming language and also with the same additional frameworks (e.g. Chai or Mocha) as they use for the unit test that they don’t have any excuses to not program tests. But in the end, we all decided and also committed together to use Nightwatch.js as the UI testing framework.

ChaiInNightwatch - Nightwatch

(chai assertion in Nightwatch.js)

ChaiJS - Nightwatch

Source: http://chaijs.com/api/bdd/#method_a

Clearly, there are also other Node.js testing frameworks (e.g. webdriver.io ) but Nightwatch.js was already used by other teams in this project. To have the possibility to exchange experience and also check on tests for other teams we decided not to look into other Node.js frameworks besides Nightwatch.js.

The start

To get a better understanding of Nightwatch.js I created some simple tests using boilerplates from Github. But unfortunately, none of them were completely working as I needed it.That’s why I began to build up my own boilerplate. However, I learned a lot from using the other boilerplates. The basic requirements are to install Node.js and Nightwatch.js.

What’s in this boilerplate

The boilerplate is build to either uses plain Nightwatch.js or cucumber with Nightwatch.js. Also included is a simple docker compose file for a selenium hub with two nodes (firefox and chrome). Setup and Usage are completely described on Github.

dockerfile - Nightwatch

Docker compose file

Positive Aspects about the Framework

During the project, the other members of my team adapt, change or also create tests. Here are some positive aspects of the setup with Nightwatch.js:

Pro’s for Developer

  • No local selenium server setup because of docker compose files/setup
  • Easy to use (Node.js)
  • Additional javascript frameworks Mocha or Chai same as UNIT tests

Pro’s for Tester

  • Easy and fast setup of the framework
  • Usable with Cucumber (BDD)
  • Many Node.js packages available to adapt the test suite

Pro’s for the whole team

  • Same testing environment (browser) for everyone through docker setup
  • Quality is a team support
  • Everyone can read the logs/reports and can fix or adapt the tests
  • Nightwatch.js is an open source project

Conclusion

I would definitely recommend using nightwatch.js for other javascript projects. But I also would always try to make the decision for a testing framework together with my team.

About Christine

Christine Zierold - Nightwatch

Christine is from Berlin and lives in Vancouver right now. She accomplishes over 10 years in tech and as a quality assurance engineer (QA) since 5 years. Christine has a background in working for small startups, medium size companies as well as in government. She worked in customer support, as a developer, as a system engineer, as a team lead but from all roles, she liked the most to be a quality assurance engineer. She is currently in the transition from working in an office for a company to work remotely from everywhere as a freelancer. Christine loves to travel and enjoys to encounter new cultures.

http://chriszie.rocks/

https://github.com/ChrisZie

https://twitter.com/ChrisZie_

https://www.linkedin.com/in/christine-zierold-20080357