node/test/es-module/test-require-module-implicit.js
Antoine du Hamel 987740399d
tools: enforce trailing commas in test/es-module
PR-URL: https://github.com/nodejs/node/pull/60891
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-12-03 14:18:40 +01:00

20 lines
521 B
JavaScript

// Flags: --experimental-require-module
'use strict';
// Tests that require()ing modules without explicit module type information
// warns and errors.
const common = require('../common');
const assert = require('assert');
{
// .mjs should not be matched as default extensions.
const id = '../fixtures/es-modules/should-not-be-resolved';
assert.throws(() => {
require(id);
}, {
code: 'MODULE_NOT_FOUND',
});
const mod = require(`${id}.mjs`);
common.expectRequiredModule(mod, { hello: 'world' });
}