Javascript jest
Table of Content
Introduction
Jest is a delightful JavaScript Testing Framework with a focus on simplicity. (Jest docs)
Mocks
Setup
The following instructions use the @sendgrid package as an example "@sendgrid/mail": "^7.4.0",
- name the mocks folder
__mocks__
- use the same folder structure where the mockfile that is getting mocked (e.g.
__mocks__/@sendgrid/mail.js
)
Example #1
mail.js
Base package.json config
With global setup
Expectations
To equal array with object containing
To equal array with string matching
Moxios
integration.test.js