JEST introduction

fig: Jest introduction
fig: Jest introduction

Unit testing is a software testing where individual units (components) of a software are tested. The purpose of unit testing is to validate that each unit of the software performs as designed.

A unit is the smallest testable part of any software.

Jest

Jest is a delightful JavaScript Testing Framework with a focus on simplicity.

  • Jest works with almost all javascript libraries and frameworks.
  • Jest allows you to write tests with an approachable, familiar and feature-rich API that gives you results quickly.

You can read Jest Documentation from below URL

https://jestjs.io/

Benefits of Jest testing

1. Fast and Safe - What makes Jest so fast? It's a combination of several factors:

* Parallelization: this is pretty obvious, and other test frameworks use it too.
* Run slowest tests first: this ensures all cores are utilized to the max.
* Caching babel transforms: reduces CPU-intensive babel transforms. 

2. Code Coverage - Generate code coverage by adding the flag --coverage. No additional setup needed. Jest can collect code coverage information from entire projects, including untested files.

3. Easy Mocking - Jest uses a custom resolver for imports in your tests, making it simple to mock any object outside of your test’s scope. You can use mocked imports with the rich Mock Functions API to spy on function calls with readable test syntax.

4. Great Exceptions - Jest comes with built-in matchers, spies, and its own extensive mocking library. It used to be based on Jasmine, so it inherited all of Jasmine's goodness. But in more recent versions Jest departed from Jasmine, yet kept the same functionality and added its own flavor and improvements.

5. Great Community Support

6. Well Documented - https://jestjs.io/

Site developed by Nikhil Karkra © 2021 | Icons made by Freepik