Created
March 26, 2021 20:59
-
-
Save corlaez/12382f97b706c964c24c6e70b45a4991 to your computer and use it in GitHub Desktop.
Sinon usage problem example
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 sinon = require("sinon"); | |
const auth = { session: () => "real" }; | |
sinon.stub(auth, "session").callsFake(() => { | |
return "fake"; | |
}); | |
console.log(auth.session());// fake as expected | |
const holdSession = auth.session;//hapens in app.js app.use(auth.session); | |
sinon.restore(); | |
console.log(auth.session()); // real as expected | |
console.log(holdSession()); // fake ... UNEXPECTED! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment