Skip to content

Commit

Permalink
test: improve coverage of SourceTextModule getters
Browse files Browse the repository at this point in the history
PR-URL: #37013
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
juanarbol authored and targos committed Jun 11, 2021
1 parent 346fc0a commit 836fba5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions test/parallel/test-vm-module-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 836fba5

Please sign in to comment.