From e4854fccfc6b4c64d4bb0956fc188003d0ec1a89 Mon Sep 17 00:00:00 2001 From: Vincent Xue Date: Mon, 17 Jul 2017 11:58:38 +0800 Subject: [PATCH] test: use regular expressions in throw assertions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test errors thrown in addons-napi/test_constructor more specifically. PR-URL: https://github.com/nodejs/node/pull/14318 Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Tobias Nießen Reviewed-By: Gireesh Punathil --- test/addons-napi/test_constructor/test.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/addons-napi/test_constructor/test.js b/test/addons-napi/test_constructor/test.js index 75c7b3678306e4..616ba6c2a2927e 100644 --- a/test/addons-napi/test_constructor/test.js +++ b/test/addons-napi/test_constructor/test.js @@ -13,7 +13,8 @@ assert.strictEqual(test_object.readwriteValue, 1); test_object.readwriteValue = 2; assert.strictEqual(test_object.readwriteValue, 2); -assert.throws(() => { test_object.readonlyValue = 3; }, TypeError); +assert.throws(() => { test_object.readonlyValue = 3; }, + /^TypeError: Cannot assign to read only property 'readonlyValue' of object '#'$/); assert.ok(test_object.hiddenValue); @@ -35,11 +36,13 @@ assert.ok(!propertyNames.includes('readonlyAccessor2')); test_object.readwriteAccessor1 = 1; assert.strictEqual(test_object.readwriteAccessor1, 1); assert.strictEqual(test_object.readonlyAccessor1, 1); -assert.throws(() => { test_object.readonlyAccessor1 = 3; }, TypeError); +assert.throws(() => { test_object.readonlyAccessor1 = 3; }, + /^TypeError: Cannot assign to read only property 'readonlyAccessor1' of object '#'$/); test_object.readwriteAccessor2 = 2; assert.strictEqual(test_object.readwriteAccessor2, 2); assert.strictEqual(test_object.readonlyAccessor2, 2); -assert.throws(() => { test_object.readonlyAccessor2 = 3; }, TypeError); +assert.throws(() => { test_object.readonlyAccessor2 = 3; }, + /^TypeError: Cannot assign to read only property 'readonlyAccessor2' of object '#'$/); // validate that static properties are on the class as opposed // to the instance