Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

testdouble

Package Overview
Dependencies
Maintainers
2
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testdouble

A minimal test double library for TDD with JavaScript

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
114K
increased by1.88%
Maintainers
2
Weekly downloads
 
Created
Source

testdouble.js

Build Status npmjs

Welcome! Are you writing JavaScript tests and in the market for a mocking library to fake out real things for you? testdouble.js is an opinionated, carefully-designed test double library maintained by, oddly enough, a software agency that's also named Test Double.

If you practice test-driven development, testdouble.js was designed to promote terse, clear, and easy-to-understand tests. There's an awful lot to cover, so please take some time and enjoy our documentation, which itself is designed to show you how to make the most out of test doubles in your tests.

Docs

All of our docs are in the docs/ directory inside this repository and numbered for easy reading in the priority-order we anticipate people needing them. Here's a rough outline:

  1. Installation
  2. for Node.js
  3. for browsers
  4. initial configuration
  5. Purpose of testdouble.js
  6. in unit tests
  7. in integration tests
  8. Getting started tutorial
  9. Creating test doubles
  10. test double functions with td.function()
  11. test double objects with td.object() 1. objects that mirror a constructor function 2. objects that mirror an object of functions 3. object of functions for an array of names 4. object of any functions using ES2015 Proxy
  12. Stubbing responses
  13. td.when() API
  14. equality argument matching
  15. one-liner stubbings
  16. stubbing sequential return values
  17. argument matchers 1. td.matchers.anything() 2. td.matchers.isA() 3. td.matchers.contains()
    1. matching strings
    2. matching arrays
    3. matching objects 4. td.matchers.argThat()
  18. Stubbing callback APIs
  19. Stub exceptions with thenThrow
  20. Stub side effects with thenDo
  21. Configuring stubbings 1. ignoreExtraArgs 2. times
  22. Verifying invocations
  23. td.verify() API
  24. equality argument matching
  25. argument matchers 1. td.matchers.anything() 2. td.matchers.isA() 3. td.matchers.contains()
    1. matching strings
    2. matching arrays
    3. matching objects 4. td.matchers.argThat()
  26. Argument captors
  27. Configuring verifications 1. ignoreExtraArgs 2. times
  28. Replacing dependencies with test doubles
  29. for Node.js 1. td.replace() API
    1. Replacing plain functions
    2. Replacing plain objects
    3. Replacing a constructor function
    4. Replacing a module that doesn't exist (yet)
  30. for Browser JS
  31. Writing custom argument matchers
  32. Debugging with testdouble.js
  33. td.explain() API
  34. Plugins
  35. testdouble-chai
  36. testdouble-jasmine
  37. Frequently Asked Questions
  38. Why doesn't td.replace() work with external CommonJS modules?

Keywords

FAQs

Package last updated on 10 Mar 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc