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

test: show pending exception error in napi tests #18413

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions test/addons-napi/test_exception/test.js
Original file line number Diff line number Diff line change
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,
'Expected exception to be pending, but' +
`it was marked as ${exception_pending}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change might be more confusing than helpful. Is "marked as false" going to help someone or confuse them?

How about this:

`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,
'Expected no exception to be pending, but' +
` it was marked as ${exception_pending}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above, although with the text changed to reverse the expectation.

}