Skip to content

Commit

Permalink
test: improve coverage of SourceTextModule getters
Browse files Browse the repository at this point in the history
  • Loading branch information
juanarbol committed Jan 21, 2021
1 parent e279304 commit feca4cf
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 feca4cf

Please sign in to comment.