
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
testdouble
Advanced tools
The goal of this project is to provide a test-framework-agnostic test double library for JavaScript which mirrors Mockito pretty closely. That means each Test Double created by the library will be a spy that is also capable of stubbing values. Other conveniences (like matchers, ordered invocation & verification, etc.) will be added, but only to the extent they benefit an isolated TDD workflow.
If you need a robust test double library that's designed to cover every possible use case, we recommend checking out Sinon.JS.
To stub with testdouble.js, first require it:
var td = require('testdouble');
Create a test double with the create
function:
myTestDouble = td.create();
You can stub a no-arg invocation like so:
td.when(myTestDouble()).thenReturn("HEY");
myTestDouble(); // returns "HEY"
You can stub a specific set of args (performs lodash's _.isEqual
on each) with:
td.when(myTestDouble('a', 5, {foo: 'bar'})).thenReturn("YES");
myTestDouble('a', 5, {foo: 'bar'}); // returns "YES"
myTestDouble('a', 5, {foo: 'baz'}); // returns undefined
The rest of the stuff we'd like to do with this is a work-in-progress. See the issues for more detail on where we're headed.
0.0.3 (2015-09-08)
Closed issues:
FAQs
A minimal test double library for TDD with JavaScript
The npm package testdouble receives a total of 75,644 weekly downloads. As such, testdouble popularity was classified as popular.
We found that testdouble demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.