0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 15:30:56 +01:00
nodejs/test/es-module/test-esm-non-js.js
Guy Bedford 250a995656
esm: disable non-js exts outside package scopes
PR-URL: https://github.com/nodejs/node/pull/30501
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2019-11-16 23:26:49 -08:00

22 lines
577 B
JavaScript

'use strict';
const common = require('../common');
const { spawn } = require('child_process');
const assert = require('assert');
const entry = require.resolve('./test-esm-json.mjs');
// Verify non-js extensions fail for ESM
const child = spawn(process.execPath, [entry]);
let stderr = '';
child.stderr.setEncoding('utf8');
child.stderr.on('data', (data) => {
stderr += data;
});
child.on('close', common.mustCall((code, signal) => {
assert.strictEqual(code, 1);
assert.strictEqual(signal, null);
assert.ok(stderr.indexOf('ERR_UNKNOWN_FILE_EXTENSION') !== -1);
}));