Closed pgayvallet closed 10 years ago
Short code is better than long speech :
// this test pass test("calls should be accessible", function() { var stub = this.stub(); stub.returns("ahah"); stub.withArgs("throw").returns("hello"); stub("foo"); stub("throw"); equal(stub.callCount, 2); ok(stub.firstCall != null); ok(stub.secondCall != null); }) // this test last asserts fails. test("throwing calls should be accessible", function() { var stub = this.stub(); stub.returns("ahah"); stub.withArgs("throw").throws("AnyException"); stub("foo"); try { stub("throw"); } catch(e) {}; equal(stub.callCount, 2); ok(stub.firstCall != null); ok(stub.secondCall != null); // <-- this fail. })
looking at the code, this is simply because the 'createCallProperties' call in invoke and withArgs is called too late in case of throwing calls.
Note : using sinon-js 1.6.0 . This example uses sinon-qunit.
Since you already have a failing test case and know how to fix it in the code, you could provide a patch ;-)
Short code is better than long speech :
looking at the code, this is simply because the 'createCallProperties' call in invoke and withArgs is called too late in case of throwing calls.