Skip to content

Instantly share code, notes, and snippets.

@mikebannister
Created December 8, 2010 15:51
Show Gist options
  • Save mikebannister/733458 to your computer and use it in GitHub Desktop.
Save mikebannister/733458 to your computer and use it in GitHub Desktop.
Wondering why I can't catch this assertion error
var assert = require('assert');
var EventEmitter = require('events').EventEmitter;
var TestEmitter = function() {
var self = this;
EventEmitter.call(this);
setTimeout(function() {
self.emit('any', false);
}, 2000);
};
TestEmitter.prototype = Object.create(EventEmitter.prototype);
var funcThatThrowsAssertionError = function(fn) {
var testEmitter = new TestEmitter();
testEmitter.on('any', function(val) {
assert.ok(val);
});
fn();
};
try {
funcThatThrowsAssertionError(function() {
console.log('done');
});
} catch(err) {
console.log(err);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment