Skip to content

Error cause not printed #233

@dwoznicki

Description

@dwoznicki

When a test encounters an unexpected error, only the top level error is printed. This makes it difficult to debug the actual underlying cause of these test failures.

For example, I have the following test which throws a null pointer.

const {test} = require("uvu");

test("error cause", () => {
    try {
        let a = null;
        a.hello();
    } catch (error) {
        throw new Error("Oh no! Something went wrong", {cause: error});
    }
});
test.run();

Running this test produces the following output.

✘   (0 / 1)

   FAIL  "error cause"
    Oh no! Something went wrong

    at Object.handler (/home/danwoz/testo/testo.js:8:15)
    at Number.runner (/home/danwoz/testo/node_modules/uvu/dist/index.js:88:16)
    at Timeout.exec [as _onTimeout] (/home/danwoz/testo/node_modules/uvu/dist/index.js:151:39)



  Total:     1
  Passed:    0
  Skipped:   0
  Duration:  2.59ms

This error would be a lot easier to debug if the original null pointer showed up in the stack trace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions