Skip to content

Commit

Permalink
fix(mocha): unwrap errors (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLow authored Sep 10, 2024
1 parent cc7d3ba commit 214c6b6
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 16 deletions.
26 changes: 23 additions & 3 deletions packages/mocha/.snapshots/1e467e89966f1dc487140f1b18eaffad/0.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,37 @@ Object {
1)
tests
fails:
Error [ERR_TEST_FAILURE]: this is an error
Error: this is an error
*
*
*
*
*
*
at async Promise.all (index 0)
*
*

2)
tests
should fail:
Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:

AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

assert(false)


+ expected - actual

-false
+true

*
*
*
*
*
*
*



Expand Down
14 changes: 12 additions & 2 deletions packages/mocha/.snapshots/1e467e89966f1dc487140f1b18eaffad/1.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,21 @@ Object {

1)
should fail:
Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:

AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

assert(false)


+ expected - actual

-false
+true

*
*
*
*
*



Expand Down
28 changes: 24 additions & 4 deletions packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/0.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,37 @@ Object {
1)
tests
fails:
Error [ERR_TEST_FAILURE]: this is an error

Error: this is an error
*
*
*
*
*
*
at async Promise.all (index 0)
*
*

2)
tests
should fail:
Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:

AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

assert(false)


+ expected - actual

-false
+true

*
*
*
*
*
*
*



Expand Down
14 changes: 12 additions & 2 deletions packages/mocha/.snapshots/4353502ed400317a687af8c8312f2662/1.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@ Object {

1)
should fail:
Error [ERR_TEST_FAILURE]: false == true


AssertionError [ERR_ASSERTION]: false == true
+ expected - actual

-false
+true

*
*
*
*
*



Expand Down
26 changes: 23 additions & 3 deletions packages/mocha/.snapshots/dc3fc117f81a81ae79e191693864201a/0.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,37 @@ Object {
1)
tests
fails:
Error [ERR_TEST_FAILURE]: this is an error
Error: this is an error
*
*
*
*
*
*
at async Promise.all (index 0)
*
*

2)
tests
should fail:
Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:

AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

assert(false)


+ expected - actual

-false
+true

*
*
*
*
*
*
*



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,23 @@ Object {

1)
should fail:
Error [ERR_TEST_FAILURE]: The expression evaluated to a falsy value:

AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

assert(false)

+ expected - actual

-false
+true

*
*
*
*
*
*
*
*


Expand Down
3 changes: 2 additions & 1 deletion packages/mocha/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class Test {
this.file = event.data.file;
this.pending = Boolean(event.data.skip || event.data.todo);
this.duration = event.data.details?.duration_ms;
this.err = event.data.details?.error;
const error = event.data.details?.error;
this.err = error?.cause instanceof Error ? error.cause : error;
this.passed = passed;
this.nesting = event.data.nesting;
}
Expand Down

0 comments on commit 214c6b6

Please sign in to comment.