Skip to content

Commit de6dca1

Browse files
juanarboltargos
authored andcommitted
test: improve coverage of SourceTextModule getters
PR-URL: #37013 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent fef6ac7 commit de6dca1

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

test/parallel/test-vm-module-errors.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,26 @@ function checkInvalidCachedData() {
235235
}
236236

237237
function checkGettersErrors() {
238+
const expectedError = {
239+
code: 'ERR_VM_MODULE_NOT_MODULE',
240+
message: /Provided module is not an instance of Module/
241+
};
238242
const getters = ['identifier', 'context', 'namespace', 'status', 'error'];
239243
getters.forEach((getter) => {
240244
assert.throws(() => {
241245
// eslint-disable-next-line no-unused-expressions
242246
Module.prototype[getter];
243-
}, {
244-
code: 'ERR_VM_MODULE_NOT_MODULE',
245-
message: /Provided module is not an instance of Module/
246-
});
247+
}, expectedError);
248+
assert.throws(() => {
249+
// eslint-disable-next-line no-unused-expressions
250+
SourceTextModule.prototype[getter];
251+
}, expectedError);
247252
});
253+
// `dependencySpecifiers` getter is just part of SourceTextModule
254+
assert.throws(() => {
255+
// eslint-disable-next-line no-unused-expressions
256+
SourceTextModule.prototype.dependencySpecifiers;
257+
}, expectedError);
248258
}
249259

250260
const finished = common.mustCall();

0 commit comments

Comments
 (0)