()
| 12 | const require = createRequire(import.meta.url); |
| 13 | |
| 14 | export async function run() { |
| 15 | // binding.node |
| 16 | { |
| 17 | const bindingPath = require.resolve(`./build/${buildType}/binding.node`); |
| 18 | // Test with order of import+require |
| 19 | const { default: binding, 'module.exports': exports } = await import(pathToFileURL(bindingPath)); |
| 20 | assert.strictEqual(binding, exports); |
| 21 | assert.strictEqual(binding.hello(), 'world'); |
| 22 | |
| 23 | const bindingRequire = require(bindingPath); |
| 24 | assert.strictEqual(binding, bindingRequire); |
| 25 | assert.strictEqual(binding.hello, bindingRequire.hello); |
| 26 | |
| 27 | // Test multiple loading of the same addon. |
| 28 | // ESM cache can not be removed. |
| 29 | delete require.cache[bindingPath]; |
| 30 | const { default: rebinding } = await import(pathToFileURL(bindingPath)); |
| 31 | assert.strictEqual(rebinding.hello(), 'world'); |
| 32 | assert.strictEqual(binding.hello, rebinding.hello); |
| 33 | } |
| 34 | } |
no test coverage detected