Last active
April 18, 2017 17:08
-
-
Save HugoDF/b73cc985aed5fcfebc914cc3df31bbb1 to your computer and use it in GitHub Desktop.
Stub getter with sinon.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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