-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: improve coverage of lib/internal/loader/ModuleMap.js #16061
Conversation
@jphblais, hi. Thank you for contributions! It may be better to use new branches for different PRs, so that their commits are not duplicated and mixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nit on comment is not blocking.
|
||
// As long as the assertion of "job" argument is done after the assertion of | ||
// "url" argument this test suite is ok. Tried to mock the "job" parameter, | ||
// but I think it's useless, and was not simple to mock... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the extra text, I think the first sentence is enough:
Tried to mock the "job" parameter, but I think it's useless, and was not simple to mock...
|
||
assert.throws(() => moduleMap.has(1), errorReg); | ||
|
||
assert.throws(() => moduleMap.has(() => {}), errorReg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We don't really need to keep all of the assertions separated by empty lines, and we usually don't do it for single-line assertions. I think it mostly blows up the visual file size in this case.
CI has some failures that appear to be unrelated. smartos15-64
smartos16-64
0,pi3-raspbian-jessie
I will self-assign and land this unless there are objections based on these test results. |
|
||
const moduleMap = new ModuleMap(); | ||
|
||
assert.throws(() => moduleMap.get({}), errorReg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: we can put these in a loop to adhere to the DRY principle:
[{}, [], true, 1, () => {}].forEach((element) => {
assert.throws(() => moduleMap.get(element), errorReg);
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should likely be made into...
common.expectsError(
() => moduleMap.get([]),
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: /^The "url" argument must be of type string/
}
);
etc
Seems like this needs to be rebased. |
Obsoleted by #15924 from same author. |
Added tests to cover the exceptions "throw'ed" in ModuleMap class.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)