Skip to content

Commit bebcdfe

Browse files
blairwilcoxMylesBorins
authored andcommitted
test: show pending exception error in napi tests
Shows the result of the wasPending in the error message if the assertion fails. Backport-PR-URL: #19265 PR-URL: #18413 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent af655f5 commit bebcdfe

File tree

1 file changed

+8
-6
lines changed
  • test/addons-napi/test_exception

1 file changed

+8
-6
lines changed

test/addons-napi/test_exception/test.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ const theError = new Error('Some error');
2020

2121
// Test that the exception thrown above was marked as pending
2222
// before it was handled on the JS side
23-
assert.strictEqual(test_exception.wasPending(), true,
24-
'VM was marked as having an exception pending' +
25-
' when it was allowed through');
23+
const exception_pending = test_exception.wasPending();
24+
assert.strictEqual(exception_pending, true,
25+
'Exception not pending as expected,' +
26+
` .wasPending() returned ${exception_pending}`);
2627

2728
// Test that the native side does not capture a non-existing exception
2829
returnedError = test_exception.returnException(common.mustCall());
@@ -44,7 +45,8 @@ const theError = new Error('Some error');
4445
` ${caughtError} was passed`);
4546

4647
// Test that the exception state remains clear when no exception is thrown
47-
assert.strictEqual(test_exception.wasPending(), false,
48-
'VM was not marked as having an exception pending' +
49-
' when none was allowed through');
48+
const exception_pending = test_exception.wasPending();
49+
assert.strictEqual(exception_pending, false,
50+
'Exception state did not remain clear as expected,' +
51+
` .wasPending() returned ${exception_pending}`);
5052
}

0 commit comments

Comments
 (0)