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 <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
juanarbol authored and targos committed Feb 2, 2021
1 parent fef6ac7 commit de6dca1
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 de6dca1

Please sign in to comment.