Skip to content

Instantly share code, notes, and snippets.

@jwoudenberg
Created October 9, 2013 18:50
Show Gist options
  • Save jwoudenberg/6906155 to your computer and use it in GitHub Desktop.
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.
/**
* 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