Skip to content

Instantly share code, notes, and snippets.

@HugoDF
Last active April 18, 2017 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HugoDF/b73cc985aed5fcfebc914cc3df31bbb1 to your computer and use it in GitHub Desktop.
Save HugoDF/b73cc985aed5fcfebc914cc3df31bbb1 to your computer and use it in GitHub Desktop.
Stub getter with sinon.
const mockNode = {
get firstChild() {
return undefined;
}
};
const stubFirstChildGetter = sinon.stub().returns(false).onFirstCall().returns(true);
sinon.stub(mockNode, 'firstChild')
.get(stubFirstChildGetter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment