jest-when: Detailed Overview & Metrics

v3.6.0(11 months ago)

This package is actively maintained.Types definitions are provided via a separate npm package: @types/jest-whenNumber of direct dependencies: 0Monthly npm downloads

Jest-when is a Jest extension that allows you to define custom behavior for function calls in your tests. It provides a simple and intuitive way to mock function calls with specific arguments and return values, making it easier to test different scenarios and edge cases in your code.

Compared to traditional Jest mocking techniques, Jest-when offers a more declarative and readable approach to defining mock behavior. It helps in writing more concise and focused test cases by specifying the exact conditions under which a function should return a certain value.

Alternatives:
sinon+
chai-as-promised+
nock+
testdouble+
jasmine-expect+
chai-spies+
ts-mockito+
sinon-chai+
easy-mock+
mock-require+

Tags: jesttestingmockingunit testsbehavior-driven development