From 82c9ef2ad50d5417db1a820b8e8040fda45812c5 Mon Sep 17 00:00:00 2001 From: Ben Wilcox Date: Sat, 27 Jan 2018 14:39:55 -0500 Subject: [PATCH 1/2] test: show pending exception error in napi tests Shows the result of the wasPending in the error message if the assertion fails. --- test/addons-napi/test_exception/test.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/addons-napi/test_exception/test.js b/test/addons-napi/test_exception/test.js index 83961411df7574..9211e55698d999 100644 --- a/test/addons-napi/test_exception/test.js +++ b/test/addons-napi/test_exception/test.js @@ -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}`); // Test that the native side does not capture a non-existing exception returnedError = test_exception.returnException(common.mustCall()); @@ -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}`); } From 1d2cc64cbdca42f471b37d5628a2faae5676e825 Mon Sep 17 00:00:00 2001 From: Ben Wilcox Date: Tue, 30 Jan 2018 20:51:16 -0500 Subject: [PATCH 2/2] test: update error message for pending exceptions Updated the error message for pending exceptions so that it was a bit more clear. --- test/addons-napi/test_exception/test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/addons-napi/test_exception/test.js b/test/addons-napi/test_exception/test.js index 9211e55698d999..787b7d78b1c72b 100644 --- a/test/addons-napi/test_exception/test.js +++ b/test/addons-napi/test_exception/test.js @@ -22,8 +22,8 @@ const theError = new Error('Some error'); // before it was handled on the JS side const exception_pending = test_exception.wasPending(); assert.strictEqual(exception_pending, true, - 'Expected exception to be pending, but' + - `it was marked as ${exception_pending}`); + '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()); @@ -47,6 +47,6 @@ const theError = new Error('Some error'); // Test that the exception state remains clear when no exception is thrown const exception_pending = test_exception.wasPending(); assert.strictEqual(exception_pending, false, - 'Expected no exception to be pending, but' + - ` it was marked as ${exception_pending}`); + 'Exception state did not remain clear as expected,' + + ` .wasPending() returned ${exception_pending}`); }