Because testdouble.js, even as a focused test double API, is quite large, we encourage users in the community to consider implementing features as plugins that decorate additional functionality on and around testdouble.js.
If you have an idea for a feature you'd like to see, please open an issue to start a discussion on the best place for that feature to live (in the core library or as a plugin).
As discussed elsewhere, testdouble.js is written to be test-library-agnostic. In
order to use the library in your test suite, you don't need a custom plugin for
your preferred testing framework. However, it may be the case that you'd prefer
to bridge the verify()
method of testdouble.js with your preferred assertion
API for aesthetic or error-handling reasons.
These plugins developed by ourselves & the community:
- testdouble-chai - Chai assertions
- testdouble-jasmine -
Jasmine
expect
matchers (by @BrianGenisio) - testdouble-qunit - QUnit assertion
Some testing frameworks have built-in module replacement systems for injecting
fakes into your tests. Depending on the framework and your configuration,
you may need a plugin to use replace()
/ replaceEsm()
in your tests:
- testdouble-jest - module mocking support for Jest users
- testdouble-vitest - module module support for Vitest users
Sometimes, it can be handy to have a ready-made shim to pull in and configure the library for various build tools. Here's what testdouble.js has so far:
- ember-cli-testdouble by @AlexBlom provides a shim for easy importing of testdouble.js by Ember projects that using Ember CLI
- karma-testdouble by @kahwee will configure Karma to load test double's browser distribution
One popular feature of Sinon.js is its fake timer API, which can be used to synchronously test code that should defer execution for a certain amount of time (for instance, when testing that a component debounces user input).
This API has been ported for use with testdouble.js by @kuy as testdouble-timers.
Previous: Debugging with testdouble.js Next: Frequently Asked Questions