sapegin / jest-cheat-sheet Goto Github PK
View Code? Open in Web Editor NEWJest cheat sheet
License: Creative Commons Zero v1.0 Universal
Jest cheat sheet
License: Creative Commons Zero v1.0 Universal
Use your cheat sheet from time to time, would love to see some information on mockReturnValue/mockResolveValue etc.
I took the liberty of writing some info about them locally, but I do not have the permissions to submit a PR
I added the following section (under mocks):
Your mocks can return values:
const callback = jest.fn().mockReturnValue(true);
const callbackOnce = jest.fn().mockReturnValueOnce(true);
Or resolve values:
const promise = jest.fn().mockResolvedValue(true);
const promiseOnce = jest.fn().mockResolvedValueOnce(true);
They can even reject values:
const failedPromise = jest.fn().mockRejectedValue("Error");
const failedPromiseOnce = jest.fn().mockRejectedValueOnce("Error");
You can even combine these:
const callback = jest.fn()
.mockReturnValueOnce(false)
.mockReturnValue(true);
// ->
// call 1: false
// call 2+: true
See #15
Issue tracker is ONLY used for reporting bugs. New features should be discussed on our slack channel. Please use stackoverflow for supporting issues.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.