-
Notifications
You must be signed in to change notification settings - Fork 30k
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: increase coverage for ModuleMap #16045
Conversation
Ping @bmeck |
Could be a duplicate. merging the two should be fine. |
@bmeck Could always land now as separate files and anyone who feels strongly about it can merge code in a subsequent PR. FWIW, I don't mind a lot of similar code in tests if it makes each test more comprehensible as a standalone entity. (For anyone generally interested in why "DRY" may not be desirable in tests, see e.g. https://stackoverflow.com/a/11837973/436641) |
@Trott I like it. |
Yep, I'd definitely lean toward clarity of tests over conciseness. |
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.
Very close. One change that I can see.
|
||
assert.throws(() => { | ||
moduleMap.get(1); | ||
}, /TypeError \[ERR_INVALID_ARG_TYPE\]: The "url" argument must be of type string/); |
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 use...
common.expectsError(
() => moduleMap.get(1),
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "url" argument must be of type string'
}
);
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.
Hi @jasnell I've update the tests to use common.expectsError as suggested
Thanks!
|
||
const { URL } = require('url'); | ||
|
||
const common = require('../common'); |
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.
Please make this the first require()
statement (just move it before require('url')
).
@jasnell I think you forgot to update your LG. @robtpaton it would be nice if you could rebase to remove the merge commit. |
79e3110
to
65a4ac2
Compare
@BridgeAR I've rebased to remove the merge commit Thanks! |
const stubModule = createDynamicModule(['default'], stubModuleUrl); | ||
const loader = new Loader(); | ||
const moduleMap = new ModuleMap(); | ||
const moduleJob = new ModuleJob(loader, stubModule.module); |
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.
CI failed across all platforms:
not ok 2040 es-module/test-esm-loader-modulemap
---
duration_ms: 0.72
severity: fail
stack: |-
internal/loader/ModuleJob.js:18
this.modulePromise = this.moduleProvider(url);
^
TypeError: this.moduleProvider is not a function
at new ModuleJob (internal/loader/ModuleJob.js:18:31)
at Object.<anonymous> (/data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/es-module/test-esm-loader-modulemap.js:19:19)
at Module._compile (module.js:616:30)
at Object.Module._extensions..js (module.js:627:10)
at Module.load (module.js:535:32)
at tryModuleLoad (module.js:478:12)
at Function.Module._load (module.js:470:3)
at Function.Module.runMain (module.js:657:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:613:3
...
new ModuleJob
needs a moduleProvider
as the third argument.
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.
I think you can just use a function that returns a never-resolving Promise
for this
ping @robtpaton - can you please address @joyeecheung / @addaleax 's comments? |
65a4ac2
to
9888535
Compare
Rebased, fixed the issue, force-pushed. Hope that's OK, @robtpaton! PTAL, especially @joyeecheung. |
Some build-specific (that is: unrelated to this PR) failures on that last CI. Here's another one: |
Add test for ModuleMap set with ModuleJob but bad url. PR-URL: nodejs#16045 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Landed in d1a9c02. Thanks for the contribution! 🎉 |
Add test for ModuleMap set with ModuleJob but bad url. PR-URL: nodejs/node#16045 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Add test for ModuleMap set with ModuleJob but bad url. PR-URL: nodejs/node#16045 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Thanks for getting this over the line @Trott |
Add test for ModuleMap set with ModuleJob but bad url. PR-URL: nodejs#16045 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Add test for ModuleMap set with ModuleJob but bad url. PR-URL: #16045 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Add test for ModuleMap set with ModuleJob but bad url. PR-URL: nodejs/node#16045 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
Checklist
Affected core subsystem(s)
test