Got a logger that's all stubs. Sometimes I want those stubs to be spies. I can't figure out how to set them back if they are spies.
logger.reset = () => {
if (!logger.error instanceof sinon.stub) {
logger.error = sinon.stub();
}
if (!logger.fatal instanceof sinon.stub) {
logger.fatal = sinon.stub();
}
for (let level of levels) {
logger[level].reset();
}
};
Didn't work. Also tried logger.error.isSinonProxy
but the isSinonProxy
is true for stubs and spies.
In the meantime I'm just going to re-stub those functions regardless of what type they are. A little wasteful but no big.
But I am curious: how can I tell the difference between a stub and a spy in my code while it's running?