Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vajahath/jest-mock-example
This is an example jest mocker. https://jestjs.io/
https://github.com/vajahath/jest-mock-example
Last synced: about 12 hours ago
JSON representation
This is an example jest mocker. https://jestjs.io/
- Host: GitHub
- URL: https://github.com/vajahath/jest-mock-example
- Owner: vajahath
- License: mit
- Created: 2019-11-26T05:21:16.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T01:42:46.000Z (about 2 years ago)
- Last Synced: 2024-04-10T18:09:49.321Z (9 months ago)
- Language: JavaScript
- Size: 602 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [Jest](https://jestjs.io/) mock example
The repo it self is an example.
- Let the external module be `external-function.js`
- The feature we want to test: `feature.js`
- Test for feature: `feature.spec.js`## Usage
- clone the repo
- `npm i`
- `npm test`### Output
```sh
➜ test npm test> [email protected] test /home/xxx/test
> jestPASS ./feature.spec.js
✓ testing my feature (4ms)console.log feature.js:6
running my featureconsole.log feature.spec.js:9
mocked barconsole.log feature.spec.js:6
mocked fooTest Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.924s, estimated 1s
Ran all test suites.
➜ test
```## Licence
MIT