testdouble.js

Docs

All of our docs are in this are numbered for easy reading in the order we anticipate people will needing them. Here’s an outline with links to each section:

  1. Installation
    1. for Node.js
    2. for browsers
    3. initial configuration
  2. Purpose of testdouble.js
    1. in unit tests
    2. in integration tests
  3. Getting started tutorial
  4. Creating test doubles
    1. test double functions with td.function()
    2. test double objects with td.object()
    3. test double constructors with td.constructor()
  5. Stubbing responses
    1. td.when() API
    2. equality argument matching
    3. one-liner stubbings
    4. stubbing sequential return values
    5. 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()
      5. td.matchers.not()
    6. Stubbing callback APIs
    7. Stub exceptions with thenThrow
    8. Stub promises with thenResolve and thenReject
    9. Stub side effects with thenDo
    10. Configuring stubbings
    11. ignoreExtraArgs
    12. times
    13. defer
    14. delay
  6. Verifying invocations
    1. td.verify() API
    2. equality argument matching
    3. 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()
    4. Argument captors
    5. Configuring verifications
      1. ignoreExtraArgs
      2. times
  7. Replacing dependencies with test doubles
    1. for Node.js
    2. for Browser JS
    3. td.replace() API
  8. Writing custom argument matchers
  9. Debugging with testdouble.js
    1. td.explain() API
  10. Using with TypeScript
    1. Interfaces
    2. Function Types
    3. Abstract and concrete classes
  11. Plugins
    1. testdouble-chai
    2. testdouble-jasmine
  12. Frequently Asked Questions
    1. Why shouldn’t I call both td.when and td.verify for a single interaction with a test double?
  13. Configuration
    1. td.config