@@ -497,21 +497,22 @@ module.exports = function shouldSaveThings () {
497
497
The above will verify that ` save ` was called with the two specified arguments.
498
498
If the verification fails (say it passed ` '010100' ` instead), testdouble.js will
499
499
throw a nice long error message to explain how the test double function was
500
- actually called, so that you can spot the error.
500
+ actually called, hopefully helping you spot the error.
501
501
502
502
Just like with ` td.when() ` , more complex cases can be covered with [ argument
503
503
matchers] ( /docs/6-verifying-invocations.md#relaxing-verifications-with-argument-matchers )
504
504
and [ configuration
505
505
options] ( /docs/6-verifying-invocations.md#configuring-verifications ) .
506
506
507
507
A word of caution: ` td.verify() ` should be needed only sparingly. When you
508
- verify a function was called (as opposed to what it returns) you're asserting
509
- that your code has a desired side effect. Code with lots of side effects is bad,
510
- so mocking libraries are often abused to make side-effect heavy code easier to
511
- test. In these cases, refactoring each dependency to return values instead is
512
- almost always the better design approach. Sometimes in the interest of
513
- completeness, people will attempt to verify an invocation that already satisfies
514
- a stub, but this is almost [ provably
508
+ verify a function was called (as opposed to relying on what it returns) you're
509
+ asserting that your subject has a side effect. Code with lots of side effects is
510
+ bad, so mocking libraries are often abused to make side-effect heavy code easier
511
+ to proliferate. In these cases, refactoring each dependency to return values
512
+ instead is almost always the better design approach. A separate test smell with
513
+ verifying calls is that sometimes—perhaps in the interest of maximal
514
+ completeness—a test will verify an invocation that already satisfied a stubbing,
515
+ but this is almost [ provably
515
516
unnecessary] ( /docs/B-frequently-asked-questions.md#why-shouldnt-i-call-both-tdwhen-and-tdverify-for-a-single-interaction-with-a-test-double ) .
516
517
517
518
### Other functions
0 commit comments