testdouble / testdouble/testdouble.js

Investigate early warnings for callback API mock misses

Open
#210 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.4k
Forks
140
Avg merge
22h
Merged PRs (30d)
1

Description

I'm currently working with testdouble.js with a callback-based API, and if I miss a stubbing, I only know that when the test times out (or when I see it hang). Looking through the API again, I don't see a way to throw an early warning (or error) for missed mocks, which would be really helpful with these callback-based APIs (i.e. request).

Commence thinking out loud:

Stubbings are currently unordered, right? One solution would be to order them, so that stubbing A has to occur before stubbing B for any given double. If that were true, then we could throw on the first miss—your invocations were out of order. Not elegant, but it could be a valid solution.

Another would be to throw on any miss. Why don't we do this currently?

I'm currently running v2.0.2, which is otherwise working really well. I hooked it into a dependable container with zero issue to replace request proper, and it's perfect. 😍

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the stubbing and invocation behavior for callback-based APIs, especially the missed-mock case described for request. Compare ordered stubbings, early warnings, and throwing on any miss, then define the expected behavior and coverage needed for the chosen approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.