Skip to content
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

suppresses thrown errors #218

Closed
jake-miles opened this issue Jan 17, 2012 · 3 comments
Closed

suppresses thrown errors #218

jake-miles opened this issue Jan 17, 2012 · 3 comments

Comments

@jake-miles
Copy link

Code that I'm testing throws an error. This error does not appear in the test output, making it difficult to determine why the test failed. It would be much more helpful if mocha always listed the stacktrace of any errors thrown during a test.

This test (along with others):

it ("creates the top-level object", function () {
var result = fillObjectTree.fillObjectTree (dataSet1, example);
result.id.should.equal (1001);
});

Produces:

✖ 17 of 58 tests failed:

  1. fill_object_tree createMap fillObjectTree creates the top-level object:

  2. fill_object_tree createMap fillObjectTree creates the measurableQuantity:

Note the lack of detail under the failed test.

If I wrap the test code in a try/catch, it outputs the error in the console output:

it ("creates the top-level object", function () {       
    try {
    var result = fillObjectTree.fillObjectTree (dataSet1, example);
    } catch (e) {
        log.error(e);
    }
    result.id.should.equal (1001);
    });

ERROR The provided object to fill (object) does not match the example object map's type (array) at path [.measurableQuantity.unitConversions], Error

@tj
Copy link
Contributor

tj commented Jan 18, 2012

mocha should display exceptions thrown, not if you try/catch obviously but otherwise it will, im not sure I get what the issue is you're having, is there something I can reproduce?

@jake-miles
Copy link
Author

Yeah, I'm unable to repro this - I've changed a number of things and something along the way fixed this problem. Part of the problem may have been that in some cases I was throwing strings instead of Error objects. If you're printing e.stack, that would of course produce no output for a string. If I hit this problem again I'll post an update.

@tj
Copy link
Contributor

tj commented Jan 18, 2012

oh, yeah dont throw strings http://www.devthought.com/2011/12/22/a-string-is-not-an-error/, they're useless

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants