Skip to content

phedinkus/testdouble.js

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code
This branch is 1 commit ahead, 1144 commits behind testdouble:main.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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. Configuring stubbings 1. ignoreExtraArgs 2. times
  19. Verifying invocations
  20. td.verify() API
  21. equality argument matching
  22. 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()
  23. Argument captors
  24. Configuring verifications 1. ignoreExtraArgs 2. times
  25. Replacing dependencies with test doubles
  26. 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)
  27. for Browser JS
  28. Writing custom argument matchers
  29. Debugging with testdouble.js
  30. td.explain() API
  31. Plugins
  32. testdouble-chai
  33. testdouble-jasmine
  34. Frequently Asked Questions
  35. Why doesn't td.replace() work with external CommonJS modules?

About

A minimal test double library for TDD with JavaScript

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 92.9%
  • CoffeeScript 7.1%