Skip to content

Instantly share code, notes, and snippets.

@mrded

mrded/foo.js

Last active Jun 1, 2018
Embed
What would you like to do?
chai-spies: How to test async callbacks
const Chai = require('chai');
const Spies = require('chai-spies');
Chai.use(Spies);
const original = function(callback) {
setTimeout(callback, 0);
};
it("async callback should be called with Spy", function() {
const callback = Chai.spy();
original(callback);
// Doesn't work here.
Chai.expect(callback).to.have.been.called();
});
it("async callback should be called without Spy", function(done) {
// Does work.
original(() => done());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.