We present to your attention a review of the most widely used testing tools for JS projects, which should be noted in 2018. Today we start with general purpose testing tools.

General Purpose Testing Tools

 

▍Jsdom

Jsdom is a JavaScript implementation of the WHATWG DOM and HTML standards. In other words, jsdom mimics the browser’s environment without performing anything other than the usual JS.

In such an environment, tests can be performed very quickly. The minus jsdom is that not everything can be simulated outside the real browser (for example, this approach will not take screenshots), so the use of this tool limits the testing capabilities.

It is worth mentioning that the JS community is working intensively on jsdom and is improving this tool. The capabilities of its current version are very close to the current browser.

▍Istanbul

The Istanbul tool allows you to analyze code coverage with unit tests. He displays detailed reports, focusing on which you can get an accurate idea of ​​what has not yet been tested in the project, and estimate the amount of work needed to improve the situation.

▍Karma

Karma allows you to run tests in the browser and in environments that resemble browsers, including jsdom.
Karma supports a testing server with a special web page, in the environment of which tests will be performed. This page can be opened in a variety of browsers. In addition, this means the possibility of remote testing using services like BrowserStack .

▍Chai

Chai is the most popular assertion making library.

NexUnexpected

Unexpected is a library for creating statements, the syntax of which is slightly different from Chai. In addition, this library is extensible, allowing you to create more advanced statements. In particular, we are talking about the use of libraries based on unexpected, for example, such as unexpected-react.

▍Sinon.JS

Sinon.JS is a powerful autonomous system that provides the ability to test JavaScript projects using so-called spyware (spy), stubs and imitations (mock). This system can work with any unit testing frameworks.

▍Testdouble.js

Testdouble.js is a less popular library that performs the same functions as Sinon, while its developers say that it solves similar problems better than Sinon. It differs in a set of features, some features of the architecture and an approach to testing, which can make it useful in many situations. Details about testdouble can be read here , here and here .

▍Wallaby

Wallaby is another tool worth mentioning. It is not free, but many users believe that it is worth the money that they ask for it. Wallaby works in the IDE (all major IDEs are supported) and performs tests corresponding to code changes. Data on test results are displayed in real time in the same place where the code is located.


Wallaby

▍Cucumber

Cucumber helps developers with writing tests in BDD. Tests are divided between the acceptance criteria files prepared using the Gherkin syntax and the test files themselves that correspond to them. Tests can be written in various languages ​​that the framework supports, including JS.

Many commands find this syntax more convenient than TDD.

Results

We reviewed the most popular web project testing tools. What exactly is right for you? Perhaps here we can say that the best architectural solutions in the field of modern web applications are a combination of common, time-tested patterns developed by the developer community and the features of a particular application. And to find what is needed for a specific project, it is possible in only one way: to experience everything that seems appropriate in practice.

You might be also interested in:

  1. Overview of modular and integration testing frameworks
  2. Overview of user interface testing tools