Skip to content

Instantly share code, notes, and snippets.

@cowchimp
Last active August 29, 2015 14:01
Show Gist options
  • Save cowchimp/6d792099ea98acdc7aab to your computer and use it in GitHub Desktop.
Save cowchimp/6d792099ea98acdc7aab to your computer and use it in GitHub Desktop.
chai as promised not working without `notify`
{
"name": "application-name",
"version": "0.0.1",
"dependencies": {
"q": "*"
},
"devDependencies": {
"mocha": "1.19.0",
"chai": "*",
"chai-as-promised": "*"
}
}
var chai = require('chai');
var assert = chai.assert;
chai.use(require('chai-as-promised'));
var Q = require('q');
test('this test should fail and ineed does so because it uses `notify`', function(done) {
var promise = getPromise();
assert.becomes(promise, 6).notify(done);
});
test('this test should fail but does not because it does not use `notify`', function() {
var promise = getPromise();
assert.becomes(promise, 6);
});
function getPromise() {
var deferred = Q.defer();
setTimeout(function() {
deferred.resolve(5);
}, 1000);
return deferred.promise;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment