New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
seneca catch error that should be catched by mocha #35
Comments
this is happening when using seneca@0.5.17 |
actually the stack trace is being modified by seneca. On the 3 lines that correspond to the test file, none match the line of the failing assert. |
0.5.18 leaves the stack alone |
I'm trying to use seneca with mocha and chai. seneca seems to be intercepting the exception generated by Is there an alternative to disable seneca error handling on act callback? |
I had the same Problem.
Would be helpful if such things would appear on the website. |
@bitterulf what do you do for negative tests -- such as a case where |
@bjonica just check if the error exist it('should generate a error', function (done) {
var s = require('seneca')({log: 'test'}).error(done);
s.act({role: 'rules', action: 'apply'}, function(err, result) {
assert(err);
});
}); |
@bjonica Hmm was not as easy as i thought but i got a sollution that worked for me. var assert = require('assert');
var createSenecaInstance = function(cb) {
var si = require('seneca')({
log: 'silent'
}).use(require('../plugins/rulePlugin.js'));
si.ready( function( err ) {
if (err) {
return cb(err);
}
cb(null, si);
});
};
describe('rulePlugin', function() {
beforeEach(function(done){
done();
});
describe('apply rules without entries', function () {
it('should generate a error', function (done) {
createSenecaInstance(function(err, si) {
si.error(function(err) {
if (err.msg == 'seneca: Action action:apply,role:rules failed: no entries.') {
done();
}
});
si.act({role: 'rules', action: 'apply' }, function(err, result) {
});
});
});
});
}); |
@bitterulf Yep, the timeout is exactly what I've been trying to fix. The ugly workaround I used to get better, faster errors was to wrap the var check = function (test, done) {
try {
test();
return done();
catch (e) {
return done(e);
}
}
...
it('prints a better message', function(done) {
si.act(action, function (err, result) {
check(function () {
expect(false).to.equal(true);
}, done);
});
}); It's ugly, but I had no luck finding a better solution. Our issue seems to be related to #134 but I'm not sure. I've been hacking away at seneca.js to find a better way to deal with this. |
0.6 error handling is a little too eager |
Thanks for giving it attention @rjrodger! |
Still the same problem with 1.0.0 |
If you use seneca with hapi (via chairo) you'll get a timeout for every exception happening on the server. By default hapi will return 500, but seneca swallows all exceptions. I like the way seneca works, but this bug currently totally destroys all the benefits for me. |
@PhilWaldmann agreed that we should handle that differently. Would rather it fails fast than times out |
This is in progress now. Merged with #398 |
I'm not sure if that is the same issue as seneca catching 'uncaught exceptions' but I have a test with 'asserts'. I'd expect the tests to fail with an error for which the stack top level line is where the assert line is, not in seneca's internals.
The test (edited):
The logs:
Trello Card
The text was updated successfully, but these errors were encountered: