I would like to test that if an error happens during fs.writeFile
a message is output to the console log. The below test do pass, but it outputs the stack trace of the error to the testing console, which is unwanted. How to avoid that?
describe('with fs error', () => {
it('should output errors to console', () => {
sandbox.stub(fs, 'writeFile').yields(new Error('write error'));
const consoleSpy = sandbox.spy(console, 'log');
history.save();
expect(consoleSpy).to.have.been.calledOnce;
});
});
via maasha
No comments:
Post a Comment