You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Where FakeDog is a constructor that can be passed to the subject or otherwise replaced and dog is a plain JavaScript object of the same set of test doubles one would get if they instantiated new FakeDog().
One point of potential confusion for users is that instantiating FakeDog multiple times will yield the same set of fake functions, so the total number of stubbings & invocations would accumulate over all FakeDog instances, which would run counter to our expectations of statefulness with instantiated objects, but would be necessary for the test to have sane access to the test double functions. Feedback on this point would be welcome.
The text was updated successfully, but these errors were encountered:
This is already basically implemented to support
td.replace()
(source) of constructors, but it's not exposed in an explicit way.Given a constructor:
One could call (in environments supporting destructured assignment):
Where
FakeDog
is a constructor that can be passed to the subject or otherwise replaced anddog
is a plain JavaScript object of the same set of test doubles one would get if they instantiatednew FakeDog()
.One point of potential confusion for users is that instantiating
FakeDog
multiple times will yield the same set of fake functions, so the total number of stubbings & invocations would accumulate over allFakeDog
instances, which would run counter to our expectations of statefulness with instantiated objects, but would be necessary for the test to have sane access to the test double functions. Feedback on this point would be welcome.The text was updated successfully, but these errors were encountered: