diff --git a/test/addons-napi/test_constructor/test.js b/test/addons-napi/test_constructor/test.js index b1762c2253b99a..92440bf49e74c1 100644 --- a/test/addons-napi/test_constructor/test.js +++ b/test/addons-napi/test_constructor/test.js @@ -13,7 +13,7 @@ assert.strictEqual(test_object.readwriteValue, 1); test_object.readwriteValue = 2; assert.strictEqual(test_object.readwriteValue, 2); -assert.throws(() => { test_object.readonlyValue = 3; }); +assert.throws(() => { test_object.readonlyValue = 3; }, TypeError); assert.ok(test_object.hiddenValue); @@ -35,8 +35,8 @@ assert.ok(propertyNames.indexOf('readonlyAccessor2') < 0); test_object.readwriteAccessor1 = 1; assert.strictEqual(test_object.readwriteAccessor1, 1); assert.strictEqual(test_object.readonlyAccessor1, 1); -assert.throws(() => { test_object.readonlyAccessor1 = 3; }); +assert.throws(() => { test_object.readonlyAccessor1 = 3; }, TypeError); test_object.readwriteAccessor2 = 2; assert.strictEqual(test_object.readwriteAccessor2, 2); assert.strictEqual(test_object.readonlyAccessor2, 2); -assert.throws(() => { test_object.readonlyAccessor2 = 3; }); +assert.throws(() => { test_object.readonlyAccessor2 = 3; }, TypeError); diff --git a/test/addons-napi/test_properties/test.js b/test/addons-napi/test_properties/test.js index fb0c19ceedb086..868c603879f1a2 100644 --- a/test/addons-napi/test_properties/test.js +++ b/test/addons-napi/test_properties/test.js @@ -12,7 +12,7 @@ assert.strictEqual(test_object.readwriteValue, 1); test_object.readwriteValue = 2; assert.strictEqual(test_object.readwriteValue, 2); -assert.throws(() => { test_object.readonlyValue = 3; }); +assert.throws(() => { test_object.readonlyValue = 3; }, TypeError); assert.ok(test_object.hiddenValue); @@ -34,8 +34,8 @@ assert.ok(propertyNames.indexOf('readonlyAccessor2') < 0); test_object.readwriteAccessor1 = 1; assert.strictEqual(test_object.readwriteAccessor1, 1); assert.strictEqual(test_object.readonlyAccessor1, 1); -assert.throws(() => { test_object.readonlyAccessor1 = 3; }); +assert.throws(() => { test_object.readonlyAccessor1 = 3; }, TypeError); test_object.readwriteAccessor2 = 2; assert.strictEqual(test_object.readwriteAccessor2, 2); assert.strictEqual(test_object.readonlyAccessor2, 2); -assert.throws(() => { test_object.readonlyAccessor2 = 3; }); +assert.throws(() => { test_object.readonlyAccessor2 = 3; }, TypeError); diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 55376328b026f2..9b82c3ff4cccf9 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -522,15 +522,19 @@ testAssertionMessage({a: undefined, b: null}, '{ a: undefined, b: null }'); testAssertionMessage({a: NaN, b: Infinity, c: -Infinity}, '{ a: NaN, b: Infinity, c: -Infinity }'); -// https://github.com/nodejs/node-v0.x-archive/issues/2893 -try { - // eslint-disable-next-line no-restricted-syntax - assert.throws(function() { - assert.ifError(null); - }); -} catch (e) { - threw = true; - assert.strictEqual(e.message, 'Missing expected exception..'); +// #2893 +{ + let threw = false; + try { + // eslint-disable-next-line no-restricted-syntax + assert.throws(function() { + assert.ifError(null); + }); + } catch (e) { + threw = true; + assert.strictEqual(e.message, 'Missing expected exception..'); + } + assert.ok(threw); } assert.ok(threw);