node/test/es-module/test-import-module-retry-require-errored.js
2025-07-16 10:57:22 +02:00

18 lines
452 B
JavaScript

// This tests that after failing to import an ESM that rejects,
// retrying with require() still throws.
'use strict';
const common = require('../common');
const assert = require('assert');
(async () => {
await assert.rejects(import('../fixtures/es-modules/throw-error.mjs'), {
message: 'test',
});
assert.throws(() => {
require('../fixtures/es-modules/throw-error.mjs');
}, {
message: 'test',
});
})().then(common.mustCall());