Created
October 9, 2013 18:50
-
-
Save jwoudenberg/6906155 to your computer and use it in GitHub Desktop.
The following is a test case of a problem I'm having writing jasmine unit tests for Q code in node. When run, this test specification will abruptly end because of the error thrown by done(). Update: Running the same test with the stand-alone version of Jasmine works fine, the test fails then. Apparently the issue is with jasmine-node.
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
/** | |
* Test case. | |
* Below are three tests. The top one should succeed. | |
* In the second one an exception is thrown, so it should fail. | |
* The last one should also fail. | |
* What happens is that the first two are executed, then jasmine drops | |
* dead when trying to execute the second one. | |
*/ | |
(function () { | |
var Q = require('q'); | |
describe('A test', function () { | |
it('Should succeed', function () { | |
expect(false).toBe(false); | |
}); | |
it('should fail with an error', function () { | |
var result = null; | |
runs(function () { | |
Q('foo') | |
.then(function () { | |
if (true) throw new Error('oops'); | |
result = true; | |
}) | |
.done(); | |
}); | |
waitsFor(function () { | |
return result; | |
}, 'result should be set', 500); | |
runs(function () { | |
expect(true).toBe(true); | |
}); | |
}); | |
it('Should fail', function () { | |
expect(true).toBe(false); | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment