Skip to content

Commit 0ff19b0

Browse files
pratik0509addaleax
authored andcommitted
test: changed error message validator
Replaced TypeError with RegEx to match the exact error message in file test/addons-napi/test_properties/test.js. The RegEx will check the validity of the error being thrown. PR-URL: #14443 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 8a9de1b commit 0ff19b0

File tree

1 file changed

+4
-3
lines changed
  • test/addons-napi/test_properties

1 file changed

+4
-3
lines changed

test/addons-napi/test_properties/test.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22
const common = require('../../common');
33
const assert = require('assert');
4+
const readonlyErrorRE = /^TypeError: Cannot assign to read only property '.*' of object '#<Object>'$/;
45

56
// Testing api calls for defining properties
67
const test_object = require(`./build/${common.buildType}/test_properties`);
@@ -12,7 +13,7 @@ assert.strictEqual(test_object.readwriteValue, 1);
1213
test_object.readwriteValue = 2;
1314
assert.strictEqual(test_object.readwriteValue, 2);
1415

15-
assert.throws(() => { test_object.readonlyValue = 3; }, TypeError);
16+
assert.throws(() => { test_object.readonlyValue = 3; }, readonlyErrorRE);
1617

1718
assert.ok(test_object.hiddenValue);
1819

@@ -42,11 +43,11 @@ assert.strictEqual(symbolDescription, 'NameKeySymbol');
4243
test_object.readwriteAccessor1 = 1;
4344
assert.strictEqual(test_object.readwriteAccessor1, 1);
4445
assert.strictEqual(test_object.readonlyAccessor1, 1);
45-
assert.throws(() => { test_object.readonlyAccessor1 = 3; }, TypeError);
46+
assert.throws(() => { test_object.readonlyAccessor1 = 3; }, readonlyErrorRE);
4647
test_object.readwriteAccessor2 = 2;
4748
assert.strictEqual(test_object.readwriteAccessor2, 2);
4849
assert.strictEqual(test_object.readonlyAccessor2, 2);
49-
assert.throws(() => { test_object.readonlyAccessor2 = 3; }, TypeError);
50+
assert.throws(() => { test_object.readonlyAccessor2 = 3; }, readonlyErrorRE);
5051

5152
assert.strictEqual(test_object.hasNamedProperty(test_object, 'echo'), true);
5253
assert.strictEqual(test_object.hasNamedProperty(test_object, 'hiddenValue'),

0 commit comments

Comments
 (0)