Tutorials

https://vvcestudio.com.br/en/tutorial/javascript/jest/
menu

Jest

What is Jest?

Jest is a unit testing library for JavaScript.
(Only in development environment)

Unit testing consists of checking the behavior of the smallest units in your application.
Technically, this would be a class or even a class method in object-oriented languages, and it would be a procedure or function in procedural and functional languages.

Unit testing is the entire application of testing on the input and output signatures of a system.
It consists of validating valid and invalid data via I/O being applied by developers or test analysts.
A unit is the smallest testable part of a computer program.

Creating tests with JEST

Install JEST
x
$ npm install --save-dev jest

If you create your application using the command:

Create a react application
x
$ npx create-react-app my-app

This already includes Jest automatically.


Create a Jest configuration file:
jest.config.js

The name of the test files must end with “.spec.js”.
Ex.: produto.spec.js


GitHub
Project with example tests with Jest:
https://github.com/ViniciusVC/api_vvc
.