New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to return fake data from spy.on(obj, 'funcName') when called ? #48
Comments
+1 I would really like to know this too! |
Hello guys, thanks for the issue! EDIT: I'm not sure if I totally understand your doubt, but I was reading this again and actually we have this: /**
* # chai.spy.returns (function)
*
* Creates a spy which returns static value.
*
* var method = chai.spy.returns(true);
*
* @param {*} value static value which is returned by spy
* @returns new spy function which returns static value
* @api public
*/ I hope it is what you guys were looking for. |
Hey @narainsagar @scaljeri and @lucasfcosta 😄 Right now the Array.prototype.push = chai.spy(function () { return undefined });
Array.prototype.push = chai.spy.returns(undefined);
Array.prototype.push = function () { return undefined; }
chai.spy.on(Array.prototype, 'push'); We've discussed before about having extra methods on the spy interface, but we'd like to move away from that (#38 has some on this, as does this comment in #35: #35 (comment)). I'll close this, because it's on the radar and will likely come as a result of #38. If you want to help out, continuing the discussion there would be awesome! |
I don't know is there any function or not!
Please let me know is it possible?
Something like that:
spy(obj, 'funcName').and.returnValue(5);
// spy will return a fake data when called`The text was updated successfully, but these errors were encountered: