Skip to content

Commit 5c0983e

Browse files
bshankarMylesBorins
authored andcommitted
test: improve error message output
Backport-PR-URL: #19265 PR-URL: #18498 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 4d43607 commit 5c0983e

File tree

1 file changed

+14
-8
lines changed
  • test/addons-napi/test_general

1 file changed

+14
-8
lines changed

test/addons-napi/test_general/test.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,25 @@ let w = {};
6363
test_general.wrap(w);
6464
w = null;
6565
global.gc();
66-
assert.strictEqual(test_general.derefItemWasCalled(), true,
66+
const derefItemWasCalled = test_general.derefItemWasCalled();
67+
assert.strictEqual(derefItemWasCalled, true,
6768
'deref_item() was called upon garbage collecting a ' +
68-
'wrapped object');
69+
'wrapped object. test_general.derefItemWasCalled() ' +
70+
`returned ${derefItemWasCalled}`);
71+
6972

7073
// Assert that wrapping twice fails.
7174
const x = {};
7275
test_general.wrap(x);
73-
assert.throws(() => test_general.wrap(x), Error);
76+
common.expectsError(() => test_general.wrap(x),
77+
{ type: Error, message: 'Invalid argument' });
7478

7579
// Ensure that wrapping, removing the wrap, and then wrapping again works.
7680
const y = {};
7781
test_general.wrap(y);
7882
test_general.removeWrap(y);
79-
assert.doesNotThrow(() => test_general.wrap(y), Error,
80-
'Wrapping twice succeeds if a remove_wrap()' +
81-
' separates the instances');
83+
// Wrapping twice succeeds if a remove_wrap() separates the instances
84+
assert.doesNotThrow(() => test_general.wrap(y));
8285

8386
// Ensure that removing a wrap and garbage collecting does not fire the
8487
// finalize callback.
@@ -87,8 +90,11 @@ test_general.testFinalizeWrap(z);
8790
test_general.removeWrap(z);
8891
z = null;
8992
global.gc();
90-
assert.strictEqual(test_general.finalizeWasCalled(), false,
91-
'finalize callback was not called upon garbage collection');
93+
const finalizeWasCalled = test_general.finalizeWasCalled();
94+
assert.strictEqual(finalizeWasCalled, false,
95+
'finalize callback was not called upon garbage collection.' +
96+
' test_general.finalizeWasCalled() ' +
97+
`returned ${finalizeWasCalled}`);
9298

9399
// test napi_adjust_external_memory
94100
const adjustedValue = test_general.testAdjustExternalMemory();

0 commit comments

Comments
 (0)