Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zakimohammed/ms-jest
JEST project for MS training.
https://github.com/zakimohammed/ms-jest
jest node-jest unit-testing
Last synced: 6 days ago
JSON representation
JEST project for MS training.
- Host: GitHub
- URL: https://github.com/zakimohammed/ms-jest
- Owner: ZakiMohammed
- Created: 2024-10-24T03:00:15.000Z (13 days ago)
- Default Branch: main
- Last Pushed: 2024-10-24T03:06:00.000Z (13 days ago)
- Last Synced: 2024-10-24T20:05:54.801Z (13 days ago)
- Topics: jest, node-jest, unit-testing
- Language: JavaScript
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JEST - Delightful JavaScript Test Framework
JEST project for MS training.
#### Topics Covered
- Initial Setup
- Test Specs and Suites
- Matchers
- Spying and Mocking
- Third-Party Packages
- Commands and CoverageCheckout the trend: https://npmtrends.com/chai-vs-jasmine-vs-jest-vs-mocha-vs-sinon
Checkout the JEST: https://jestjs.io/
#### Install JEST
```
npm i jest
npm i @types/jest
```#### Creating Script in package.json
```
"scripts": {
"test": "jest",
}
```#### Creating a Function
sum.js
```
const sum = (num1, num2) => num1 + num2module.exports = sum
```#### Writing Test Case
sum.test.js
```
const sum = require('./sum')test('should add num 1 and num 2', () => {
expect(sum(10, 20)).toBe(30)
})
```#### Execute Test Cases
```
npm test> [email protected] test
> jestPASS basics/sum.test.js
√ should add num 1 and num 2 (2 ms)Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.666 s, estimated 1 s
Ran all test suites.```
#### Extra Scripts
```
"scripts": {
"test": "jest",
"test:watch": "jest --watchAll",
"test:verbose": "jest --verbose",
"test:coverage": "jest --coverage",
"test:all": "jest --watchAll --verbose --coverage",
}
```#### Extra Executes
```
npm test
npm run test:watch
npm run test:verbose
npm run test:coverage
npm run test:all
```