Last active
August 29, 2015 14:01
-
-
Save cowchimp/6d792099ea98acdc7aab to your computer and use it in GitHub Desktop.
chai as promised not working without `notify`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "application-name", | |
"version": "0.0.1", | |
"dependencies": { | |
"q": "*" | |
}, | |
"devDependencies": { | |
"mocha": "1.19.0", | |
"chai": "*", | |
"chai-as-promised": "*" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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