diff --git a/test/process-module/test.mjs b/test/process-module/test.mjs index f90b7c5..6998528 100644 --- a/test/process-module/test.mjs +++ b/test/process-module/test.mjs @@ -1,12 +1,21 @@ -import { register } from 'module' import * as assert from 'assert' +import * as mod from 'module' -register('../../hook.mjs', import.meta.url) +const [major, minor] = process.versions.node.split('.').map(Number) -const rootExports = await import('../fixtures/re-export-star-external.mjs') -assert.equal(rootExports.foo, 'bar') -console.log('export * from \'some-external-module\'\n ✅ contains exports: foo') +if (!((major >= 21) || (major >= 18 && minor >= 19) || (major >= 20 && minor >= 6))) { + console.log('skipping test due to requiring Node.js >= v18.19.0 or v20.6.0') + process.exit(0) +} -const namedExports = await import('../fixtures/sub-directory/re-export-star-external.mjs') -assert.equal(namedExports.bar, 'baz') -console.log('export * from \'some-external-module/sub\'\n ✅ contains exports: bar') +mod.register('../../hook.mjs', import.meta.url) + +import('../fixtures/re-export-star-external.mjs').then(exports => { + assert.equal(exports.foo, 'bar') + console.log('export * from \'some-external-module\'\n ✅ contains exports: foo') +}) + +import('../fixtures/sub-directory/re-export-star-external.mjs').then(exports => { + assert.equal(exports.bar, 'baz') + console.log('export * from \'some-external-module/sub\'\n ✅ contains exports: bar') +})