Top Eight JavaScript Automation Testing Frameworks In 2019

DZone 's Guide to

Top Eight JavaScript Automation Testing Frameworks In 2019

Find the right JS automation testing framework for you.

· Web Dev Zone ·
Free Resource

We are progressing towards an era of automation. Every company — whether it is a startup or a large-scale enterprise — is striving to incorporate automation testing in their release cycles as efficiently as they can; testing drastically reduces the effort involved in validating repetitive test scenarios. JavaScript is no longer referred to as a developer-only programming language. With the increasing demand for automation testing, JavaScript testing frameworks have emerged to fulfill different purposes. Some are fit for unit testing, while others are made for E2E(End-to-End) testing. It is no wonder that automation testers throughout the globe have become fond of these JavaScript automation testing frameworks.

The variety of JavaScript automation testing frameworks made available for automation testers has become a cause of confusion for many. It is only natural; the more options you have in front of you, the more time it will take for you to decide which JavaScript automation testing framework fits the best for you.

Don’t worry though! I am going to highlight the eight JavaScript automation testing frameworks that make testing easier based on your testing requirements. 

1. Jest

jest framework


Rated as the number one JavaScript automation testing framework in 2018 by the stateofjs survey, Jest was developed by Facebook and used to test JavaScript codes, especially applications developed using React JS.

Jest popularity over time

Jest's popularity over time

Prerequisites for Installation

The thing that makes Jest special is that it provides an integrated framework that does not require any experience for configuration. The tool is ready to use, and if you are using npm, you can set it up instantly by running the following command.

npm install --save-dev jest

What Makes Jest a Popular JavaScript Automation Testing Framework?

  • The biggest benefit of using Jest is the out-of-the-box experience of minimal configuration and setup since it comes with a mocking support and assertion library. Just like any new testing libraries, the test cases are written using the behavior-driven development approach. You can put your test cases in a folder named _tests_ and start running them.
  • Jest is considered a very well documented and fast performing JavaScript testing framework.
  • Jest offers a robust developer tooling with less error-prone code.
  • The framework can also perform visual regression tests by capturing screenshots. When an application is developed using React JS, this feature comes quite handy for preventing UI bugs caused accidentally. It works by recording a screenshot of the rendered component and comparing it with components rendered in the future. The screenshots can be updated easily if any new feature is added.

Areas Where Jest Can Do Better

  • Compared to frameworks like Jasmine, Jest does not support that much libraries or tooling, which can sometimes come in handy for debugging test cases in IDEs that do not support Jest.
  • People who are not comfortable using Jest have stated the learning curve is pretty steep.
  • Snapshot testing with Jest is not feasible for larger snapshots files.

Is Jest for You?

Well, whether you want to use Jest or Jasmine depends entirely on your requirements. If your project requires debugging test cases in an IDE that does not support Jest, Jasmine is obviously the best choice. Still, I would suggest giving Jest a shot; it is totally worth it because of the investment Facebook is currently making and the positive experience that the React developers community is getting.

2. Mocha

Mocha is a JavaScript-based automated test framework meant for testing applications that run using Node.js. Mocha is rated as the second-best JavaScript automation testing framework according to the stateofjs survey of 2018.

Mocha framework


Prerequisites for Installation

Installation is very simple. You only need a workstation to install Mocha using the following commands.

For global installation run the below command:

npm i –global mocha

If you want to install mocha as a dependency for development, run

npm i –save-dev mocha

What Makes Mocha a Popular JavaScript Automation Testing Framework?

Developers as well as testers like Mocha for many reasons:

  • The application is open source and allows flexibility.
  • It can easily support generators.
  • Since it is old, there are many tutorials and documents available online.
  • Sequential execution of test cases with flexible reporting.
  • Mocha helps you to easily map exceptions with the relevant test cases.

Areas Where Mocha Can Do Better

  • Mocha can do better with developer tooling.
  • With the emergence of Jest, Mocha has significantly reduced in popularity in the tester community.
  • Mocha could do better in terms of overall performance and on-board features.

Is Mocha for You?

Well, the time required for setup and configuration makes Mocha a less popular framework. Organizations who have switched to Jest have found no better alternative. Jest makes testing significantly faster with very little requirement for configuration. Although the ecosystem of Mocha is quite vast, the complexity that comes with it is not sometimes worth it.

3. Jasmine



Jasmine, mostly used for asynchronous testing, is a feature-rich JavaScript automation testing framework for JavaScript. The application runs on Node.js and allows accurate and flexible bug reporting by serially running test cases. Jasmine is ranked number three JavaScript testing framework according to stateofjs 2018.

Jasmine popularity over time

Jasmine's popularity over time

Prerequisites for Installation

Installation of Jasmine is very simple. All you need is a work station with internet connectivity. Run the below command in cmd/terminal for installing Jasmine.

npm install -g jasmine

However, configuration here is a bit more complicated than Jest. You have to set up and configure the test.js file before running the test cases.

What Makes Jasmine a Popular JavaScript Automation Testing Framework?

  • The biggest strength of Jasmine is its compatibility across every framework or library of your choice, making it one of the most flexible JavaScript testing frameworks. Whether you want to use Sinon for mocking or Chai for asserting test cases, Jasmine will help you without any difficulties.
  • The community of Jasmine is quite large, and you will get all kinds of support in the form of libraries, blog posts, or video tutorials.
  • With a bigger community, the learning curve is very smooth for Jasmine. You get pretty impressive documentation too.
  • Jasmine offers an elegant programming style and patterns.

Areas Where Jasmine Can Do Better

  • Jasmine requires a significant amount of configuration. The user has to choose a mocking framework or an assertion library explicitly before using it. If your project requires this flexibility, it can be useful. If not, the configuration procedure can be a bit frustrating.
  • Jasmine supports snapshot testing by using the jasmine-snapshot library. However, integrating it can be a bit difficult.
  • The popularity of Jest has led to diminishing popularity of Jasmine.

Is Jasmine for You?

If your project is large and requires integration with external libraries, then Jasmine is the best choice because of its age and large user base. If your project is small, especially if you are using React JS, we would suggest using Jest because of its rising popularity among other users.

Now, that we are done with the top three testing frameworks as per stateofjs 2018, I will be highlighting some frameworks that are not a part of the survey but are considered very useful by the testing community.

4. Nightwatch



For automated web application testing, especially apps that are developed using Node.js, Nightwatch is a powerful automated framework that uses Selenium WebDriver API and allows the user to perform end-to-end testing. The primary objective of Nightwatch is to simplify the process of writing automated test cases and help to set up continuous integration in your development cycle.

Prerequisites for Installation

Since Nightwatch is meant for testing Node.js applications, your workstation should have the latest stable version of Node.js installed. Npm is needed for installing the framework.

For running the framework locally, you will also need a standalone Selenium server, along with the WebDriver API. This will help you to test applications locally using Firefox or Chrome.

Once your workstation is ready, run the following command in cmd.

$npm install Nightwatch

What Makes Nightwatch a Popular JavaScript Automation Testing Framework?

  • First of all, the setup is quite easy; you will only need to import the Selenium library.
  • The community is large, and there are many resources available in the form of blogs and tutorials if you need any help regarding setup or writing test cases.
  • The language is very simple. You will only need a basic knowledge of object-oriented programming.
  • If the tester belongs to a Java team, the backend team members can pick up the knowledge easily and help testers to write automated test cases, thereby increasing the overall productivity of your team.

Areas Where Nightwatch Can Do Better

  • The test cases are not that as readable as other frameworks. The syntax is not clear and it is not possible for users to write a clear description for each and every step. (You can technically do this with comments, but if any test cases fail, they won’t be displayed in the logs.)
  • To find where you went wrong, you can add a clear error message for each step, but it will make maintaining a clean syntax difficult.

Is Nightwatch for You?

For an end-to-end-testing of Node.js based web applications, Nightwatch is obviously the best, but if you think about the bigger picture, it has a lot of dependencies. You don’t have that much choice of using external unit testing applications. Additionally, Nightwatch has less support than Protractor or WebDriverIO.

5. Protractor



We have got Jest for automated testing of React JS applications, but what about Angular developers? Being one of the oldest and popular frameworks for developing single-page applications, it's good to have a framework dedicated to testing Angular JS and Angular applications. Protractor is here to the rescue. It is an end to end automation testing framework dedicated for testing your angular application in a real browser, making automated interaction just like a real user.

Prerequisites for Installation

First of all, you will need to have npm and Angular installed in your system. We hope you already have that since you are developing an Angular application. You will also need a Selenium server, which will enable the application to run cross-browser compatible test cases. Once your system is set up, run the following command in cmd

npm install -g protractor

That’s it. You are good to go. Start writing test cases and have fun testing your Angular application.

What Makes Protractor a Popular JavaScript Automation Testing Framework?

  • Since the framework runs over Selenium WebDriver, it makes cross-browser testing easier. All the basic functionalities of WebDriver are supported by Protractor.
  • Compared to Selenium WebDriver, you will have additional locators like repeater, model, and binding.
  • You can easily write and manage page objects.
  • There is a default waits functionality, the purpose of which is to wait for Angular, which is absent in WebDriver.
  • If your application is developed using a behavior-driven approach, this framework is perfect, since it supports frameworks like Cucumber, Jasmine, Mocha, etc.
  • Automated screenshot capturing and comparing is much easier in Protractor.
  • The framework also supports parallel execution of test cases across multiple workstations.

Areas Where Protractor Can Do Better

  • The biggest disadvantage is that the framework does not provide much support on browsers other than Chrome.
  • It does not support Robot classes.
  • Community support is small when compared to Selenium, which has been in the market for a longer time.

Is Protractor for You?

Once again, Protractor is the best framework for testing Angular applications, but since it works only for Chrome, it’s better to use Selenium if your project demands cross-browser testing. Selenium works fine for Angular applications and providing XPath will also define waits and other locators. Selenium also has huge community support and makes cross-browser testing easier because of its support over multiple browsers.

6. Selenium Webdriver


Selenium WebDriver

Speaking of JavaScript automation testing frameworks, Selenium WebDriver is certainly the most widely accepted and loved automation testing framework for web-applications. You can use Selenium for performing automated cross-browser testing in a thorough manner. The fact that it is open-source makes Selenium WebDriver one of the top JavaScript automation testing frameworks in the industry. Not only can you use Selenium to perform automation testing with JavaScript, but you can also use it for other programming languages too.

What Makes Selenium a Popular JavaScript Automation Testing Framework?

  • The IDE is open source, hence it can be easily learned by testers who are new in the industry or someone who wants to get introduced to web testing.
  • Because of Selenium's age, the community of Selenium is quite huge, and for any help or query, the community is always there to resolve your problem.
  • Although it has its own language, it offers language bindings to support coding in Java, JavaScript, PHP, etc.

Areas Where Selenium Can Do Better

  • The framework is open-source and supported by a community, so you will not get an instant solution to any of your problems.
  • For utilizing the complete features of Selenium, you will need third-party plugins.
  • Scalability – You cannot perform parallel testing with Selenium WebDriver. This is why Selenium came up with Selenium Grid to help you run multiple tests in parallel. A shortcoming with Selenium Grid is that it would require a heavy infrastructure if you have a large test suite and need multiple tests to run in parallel.

Is Selenium for You?

When it comes to automated cross-browser testing, there is no better framework than Selenium. The pros of Selenium highly outweigh the cons, and the fact that it comes free of cost makes it a preferred tool by many organizations. The issues that testers are currently facing with old documentation and lack of plugins are soon going to be resolved with the launch of Selenium 4.

7. Puppeteer (Library)



Puppeteer is another Node.js based automated testing library that provides an API that helps users to control Chrome by overriding the standard DevTools protocol. Many tests that can be done manually in the browser can be automated with the help of Puppeteer

Prerequisites for Installation

Puppeteer will require your workstation to have the latest version of Chrome along with Chromium. You will also need to have yarn or npm installed in your system. Node.js is again another must-have since the framework is meant for testing Node.js based web applications.

What Makes Puppeteer So Popular?

Automation scripts written using Puppeteer overrides the DevTools Protocol API. Instead of crafting web sockets payloads, calling an API will automatically

  • Launch chrome.
  • Open a new tab in the browser.
  • Navigate to the desired site for testing.
  • Capture a screenshot and close the browser.

Puppeteer allows users to mock resources, thereby avoiding reliability, consistency, and speed issues. Users can manipulate external resources like CSS selectors to make a specific test case execute faster.

Areas Where Puppeteer Can Do Better

Puppeteer’s biggest disadvantage is that it works only with Chrome. If your project demands the application to be cross-browser compatible, you will have to depend on NightWatch or other frameworks to test the application across other browsers.

Is Puppeteer for You?

The fact that it makes headless testing easier is the main reason behind the popularity of Puppeteer. However, as mentioned earlier, it only makes sense to use Puppeteer if you are developing an application that is to be used exclusively in Chrome. If you are developing a cross-browser compatible web application, you can go for TestCafe, Nightwatch, or other frameworks that make an end to end testing easier across multiple browsers.

8. Karma (Test Runner)

karma js


Karma testing

Karma testing

Karma was developed to bring a testing environment to developers. An environment where they have to worry less about configuration. They can only write code and get feedback instantly from the test cases.

Prerequisites for Installation

Since the application is based on Node.js, you will need to have Node.js installed on your system. After that, you can install Karma globally by running the following command on CMD.

npm install -g karma

What Makes Karma So Popular?

  • Karma helps you to easily perform automation testing on real devices and browsers. You can run test cases on tablets, phones, or event on a PhantomJS-like headless instance.
  • You can control the entire workflow directly from your IDE or CMD. You only need to save a file, and the framework will run the test cases for you.
  • You can run test cases with Mocha, Jasmin, QUnit, or an adapter of your choice.
  • Since the application is open source, you will find help from the community.
  • It also supports continuous integration using Jenkins, Semaphore or Travis.

Areas Where Karma Can Do Better

Well, surprisingly there are not any notable disadvantages of using Karma

Is Karma for You?

Currently, Karma is considered to be one of the best JS frameworks. When compared to Jest, Jest has many unfixed bugs and does not support .mjs files on a native environment. Even, a single error has multiple error messages for Jest. However, these issues are not present in Karma.

Published at DZone with permission of Arnab Roy. See the original article here.

Opinions expressed by DZone contributors are their own.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}