Skip to content

Commit

Permalink
test: show pending exception error in napi tests
Browse files Browse the repository at this point in the history
Shows the result of the wasPending in the error message if the
assertion fails.

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>
  • Loading branch information
reccanti authored and BridgeAR committed Feb 1, 2018
1 parent b0b2045 commit 0c16b18
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/addons-napi/test_exception/test.js
Expand Up @@ -20,9 +20,10 @@ const theError = new Error('Some error');

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

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

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

0 comments on commit 0c16b18

Please sign in to comment.