Skip to content

Instantly share code, notes, and snippets.

@AccaliaDeElementia
Created August 4, 2017 01:29
Show Gist options
  • Save AccaliaDeElementia/c68ddbc0b49d12e1eec9079a28370c68 to your computer and use it in GitHub Desktop.
Save AccaliaDeElementia/c68ddbc0b49d12e1eec9079a28370c68 to your computer and use it in GitHub Desktop.
const sinon = require('sinon')
class TestObject {
someFunction() {
console.error('sinon should stub me!');
}
}
const sandbox = sinon.sandbox.create();
const instance = new TestObject();
const stub = sandbox.stub(instance, 'someFunction'); // This fails on Sinon 3.0, it worked on Sinon 2.x
accalia_de_elementia:~/workspace/sinon_issue_repro $ npm install sinon
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN chat-example@0.0.0 No repository field.
npm WARN chat-example@0.0.0 No license field.
+ sinon@3.0.0
added 13 packages in 6.57s
accalia_de_elementia:~/workspace/sinon_issue_repro $ node example.js
/home/ubuntu/workspace/node_modules/sinon/lib/sinon/collection.js:90
throw new TypeError("Cannot stub non-existent own property " + valueToString(property));
^
TypeError: Cannot stub non-existent own property someFunction
at Object.stub (/home/ubuntu/workspace/node_modules/sinon/lib/sinon/collection.js:90:19)
at Object.<anonymous> (/home/ubuntu/workspace/sinon/example.js:12:22)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3
accalia_de_elementia:~/workspace/sinon_issue_repro $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment