BaseCase/testdouble-chai

Show detailed message from testdouble

Opened this issue · 1 comments

testdouble creates quite useful message when a verification is failed.
testdouble-chai generates more concise message which is lacking helpful data sometimes.
For example,

testdouble.verify( stub(), {times: 0, ignoreExtraArgs: true} );

generates the following message:

Error: Unsatisfied verification on test double `bound `.
  Wanted:
    - called with `()` 0 times, ignoring any additional arguments.
  But was actually called:
    - called with `("[test]", "debug")`.

Whereas the corresponding assertion

expect( stub ).not.to.have.been.called;

prints the following error:

AssertionError: expected [test double for "bound "] not to have been called, but it was.

Is it possible to have more detailed error messages containing data about call arguments?
Sometimes it can be very useful to find and fix tests.

Hi @gamtiq, thanks for the note!

I think for the strict .not.to.have.been.called case, I want to keep it just a simple boolean result by default. I do think there's room for a new assertion that exposes more of the info testdouble.js makes available, though. Maybe something like .to.have.been.called.(3).times (but not exactly that syntax, probably).

I also see that chai itself has some config variables that control how much data it prints out. I hadn't noticed those before; there's probably room to add our own config vars in testdouble-chai to control the behavior you're talking about.

I'll leave this issue open as a reminder to think about that. In the meantime, if you need the extra data, I'd say just drop down to using td's own verify. Hopefully I'll have a chance to add some stuff soon!