From d9293a38114a67aff2eecf7017b2d0dcede59776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Arboleda?= Date: Wed, 20 Jan 2021 22:09:51 -0500 Subject: [PATCH] test: improve coverage of `SourceTextModule` getters PR-URL: https://github.com/nodejs/node/pull/37013 Reviewed-By: Darshan Sen Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott --- test/parallel/test-vm-module-errors.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-vm-module-errors.js b/test/parallel/test-vm-module-errors.js index 25b43c3e4df9d0..0d5610d140419f 100644 --- a/test/parallel/test-vm-module-errors.js +++ b/test/parallel/test-vm-module-errors.js @@ -235,16 +235,26 @@ function checkInvalidCachedData() { } function checkGettersErrors() { + const expectedError = { + code: 'ERR_VM_MODULE_NOT_MODULE', + message: /Provided module is not an instance of Module/ + }; const getters = ['identifier', 'context', 'namespace', 'status', 'error']; getters.forEach((getter) => { assert.throws(() => { // eslint-disable-next-line no-unused-expressions Module.prototype[getter]; - }, { - code: 'ERR_VM_MODULE_NOT_MODULE', - message: /Provided module is not an instance of Module/ - }); + }, expectedError); + assert.throws(() => { + // eslint-disable-next-line no-unused-expressions + SourceTextModule.prototype[getter]; + }, expectedError); }); + // `dependencySpecifiers` getter is just part of SourceTextModule + assert.throws(() => { + // eslint-disable-next-line no-unused-expressions + SourceTextModule.prototype.dependencySpecifiers; + }, expectedError); } const finished = common.mustCall();