()
| 71 | } |
| 72 | |
| 73 | async function main() { |
| 74 | { |
| 75 | // Importing with absolute path as filename. |
| 76 | tmpdir.refresh(); |
| 77 | const filename = tmpdir.resolve('index.js'); |
| 78 | const options = { |
| 79 | filename, |
| 80 | importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, |
| 81 | }; |
| 82 | await testNotFoundErrors(options); |
| 83 | await testLoader(options); |
| 84 | } |
| 85 | |
| 86 | { |
| 87 | // Importing with file:// URL as filename. |
| 88 | tmpdir.refresh(); |
| 89 | // We use a search parameter to bypass caching. |
| 90 | const filename = url.pathToFileURL(tmpdir.resolve('index.js')).href + '?t=1'; |
| 91 | const options = { |
| 92 | filename, |
| 93 | importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, |
| 94 | }; |
| 95 | await testNotFoundErrors(options); |
| 96 | await testLoader(options); |
| 97 | } |
| 98 | |
| 99 | { |
| 100 | // For undefined or non-path/URL filenames, import() should resolve to the cwd. |
| 101 | tmpdir.refresh(); |
| 102 | process.chdir(tmpdir.path); |
| 103 | const undefinedOptions = { |
| 104 | importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, |
| 105 | }; |
| 106 | const nonPathOptions = { |
| 107 | filename: 'non-path', |
| 108 | importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, |
| 109 | }; |
| 110 | // Run the error tests first to avoid caching. |
| 111 | await testNotFoundErrors(undefinedOptions); |
| 112 | await testNotFoundErrors(nonPathOptions); |
| 113 | |
| 114 | await testLoader(undefinedOptions); |
| 115 | await testLoader(nonPathOptions); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | main().then(common.mustCall()); |
no test coverage detected
searching dependent graphs…