domenic/sinon-chai — Issue #4: AssertError / Assertion error - information dropped?
Author: michaelsbradleyjr
Created: 2012-03-02 05:04:41+00:00
State: open

As I've been learning my way around sinon spies and sinon-chai, I realized today that sinon-chai's `AssertionError` messages contain less information than sinon's native `AssertError` equivalents.

In short, the native sinon message indicates the arguments a spy was actually called with, in addition to the expected arguments. Whereas sinon-chai reports only the latter.

I tried adding `chai.Assertion.includeStack = true` to my suites, but that didn't make a difference.

**Example:**

```coffeescript
( expect spy ).to.have.been.calledWithExactly 'a', 'b', 'c', 'd'
```

*`AssertionError` from sinon-chai, in the context of mocha, will look like...*

```
1) ... test description ...:
AssertionError: expected spy to have been called with exactly 'a', 'b', 'c', 'd'
```

**Now with sinon's native assert:**

```coffeescript
sinon.assert.calledWithExactly spy, 'a', 'b', 'c', 'd'
```
*`AssertError` will look like...*

```
1) ... test description
AssertError: expected spy to be called with exact arguments a, b, c, d
spy(a, b, c)
... stack trace ...
... stack trace ...
```

Note the line just below the `AssertError` line and above the stack trace lines. It provides some rather helpful information.

I tried poking at the sources for sinon-chai and sinon, but wasn't able to figure out what needs to be changed.

By the way, thanks for sinon-chai, it's a great tool!