diff --git a/test/parallel/test-whatwg-webstreams-encoding.js b/test/parallel/test-whatwg-webstreams-encoding.js index b2b18df73bf1fe..24d9bce7cc5212 100644 --- a/test/parallel/test-whatwg-webstreams-encoding.js +++ b/test/parallel/test-whatwg-webstreams-encoding.js @@ -45,32 +45,15 @@ const kEuro = Buffer.from([0xe2, 0x82, 0xac]).toString(); assert.strictEqual(tds.encoding, 'utf-8'); assert.strictEqual(tds.fatal, false); assert.strictEqual(tds.ignoreBOM, false); - - assert.throws( - () => Reflect.get(TextDecoderStream.prototype, 'encoding', {}), { - name: 'TypeError', - message: /Cannot read private member/, - }); - assert.throws( - () => Reflect.get(TextDecoderStream.prototype, 'fatal', {}), { - name: 'TypeError', - message: /Cannot read private member/, - }); - assert.throws( - () => Reflect.get(TextDecoderStream.prototype, 'ignoreBOM', {}), { - name: 'TypeError', - message: /Cannot read private member/, - }); - assert.throws( - () => Reflect.get(TextDecoderStream.prototype, 'readable', {}), { - name: 'TypeError', - message: /Cannot read private member/, - }); - assert.throws( - () => Reflect.get(TextDecoderStream.prototype, 'writable', {}), { - name: 'TypeError', - message: /Cannot read private member/, - }); + ['encoding', 'fatal', 'ignoreBOM', 'readable', 'writable'].forEach((getter) => { + assert.throws( + () => Reflect.get(TextDecoderStream.prototype, getter, {}), { + name: 'TypeError', + message: /Cannot read private member/, + stack: new RegExp(`at get ${getter}`) + } + ); + }); } { @@ -91,20 +74,13 @@ const kEuro = Buffer.from([0xe2, 0x82, 0xac]).toString(); ]).then(common.mustCall()); assert.strictEqual(tds.encoding, 'utf-8'); - - assert.throws( - () => Reflect.get(TextEncoderStream.prototype, 'encoding', {}), { - name: 'TypeError', - message: /Cannot read private member/, - }); - assert.throws( - () => Reflect.get(TextEncoderStream.prototype, 'readable', {}), { - name: 'TypeError', - message: /Cannot read private member/, - }); - assert.throws( - () => Reflect.get(TextEncoderStream.prototype, 'writable', {}), { - name: 'TypeError', - message: /Cannot read private member/, - }); + ['encoding', 'readable', 'writable'].forEach((getter) => { + assert.throws( + () => Reflect.get(TextDecoderStream.prototype, getter, {}), { + name: 'TypeError', + message: /Cannot read private member/, + stack: new RegExp(`at get ${getter}`) + } + ); + }); }