Skip to content

Add td.func().reset() to reset spy/stub state - #551

Closed
MatrixNeoKozak wants to merge 1 commit into
testdouble:mainfrom
MatrixNeoKozak:fix/add-td-func-reset-to-reset-spy-stub-state-1791876746773
Closed

MatrixNeoKozak wants to merge 1 commit into
testdouble:mainfrom
MatrixNeoKozak:fix/add-td-func-reset-to-reset-spy-stub-state-1791876746773

Conversation

@MatrixNeoKozak

Copy link
Copy Markdown

What

Allows resetting individual test double spy/stub state by calling .reset() on the test double instance, avoiding the need to recreate or replace module dependencies between test cases.

Why

This change resolves the target issue or improvement.

How to test

Verify that the project builds/runs correctly and the specific bug/improvement is addressed.

Fixes #529

@rosston

rosston commented Oct 28, 2026

Copy link
Copy Markdown
Member

Closing. This adds an own reset property to every function double, which changes td.explain's children output and clobbers the child double when the imitated function already has a reset member (9 existing tests in test/safe/explain.test.js fail). The added test also records a call before asserting callCount === 0.

The first question to settle, in #529, is whether the issue should be fixed, and then what the API should be.

@rosston rosston closed this Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: td.func().reset() (reset spy/stub state)

2 participants