-
-
Notifications
You must be signed in to change notification settings - Fork 780
Description
- Sinon version : 2.3.8
- Environment : Node.js 6.9.5
- Example URL : N/A
- Other libraries you are using: Karma
What did you expect to happen?
I expected sinon to either throw an error immediately or stub the method despite it not existing yet (I think the first one is better to make errors due to typos more obvious).
What actually happens
Essentially nothing. object.missingMethod is undefined after the call but the call doesn't error either.
How to reproduce
'use strict';
const sinon = require('sinon')
describe('stub for missing method', function() {
beforeEach(function() {
this.test = {};
sinon.stub(this.test, 'foo');
});
it('should exist if it didn\'t error in the beforeEach', function() {
this.test.foo();
sinon.assert.calledOnce(this.test.foo);
});
});
The test will break on this.test.foo() since it is still undefined. My sinon version is outdated, but looking at function stub(object, property), it seems this would also be an issue in the newest version. EDIT: Looking closer, I don't think is a problem in 3.X. If you don't fix old versions and can't reproduce this in 3.X, this issue is irrelevant.
If this is indeed an issue, I will try to address it along with the other issue I have open this weekend.