0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/es-module/test-esm-no-extension.js
Geoffrey Booth 96e46d37c4
esm: replace --entry-type with --input-type
New flag is for string input only

PR-URL: https://github.com/nodejs/node/pull/27184
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2019-04-16 12:41:59 -04:00

35 lines
971 B
JavaScript

'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
const { spawn } = require('child_process');
const assert = require('assert');
const entry = fixtures.path('/es-modules/package-type-module/noext-esm');
// Run a module that does not have extension.
// This is to ensure that "type": "module" applies to extensionless files.
const child = spawn(process.execPath, [
'--experimental-modules',
entry
]);
let stderr = '';
child.stderr.setEncoding('utf8');
child.stderr.on('data', (data) => {
stderr += data;
});
let stdout = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', (data) => {
stdout += data;
});
child.on('close', common.mustCall((code, signal) => {
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
assert.strictEqual(stdout, 'executed\n');
assert.strictEqual(stderr, `(node:${child.pid}) ` +
'ExperimentalWarning: The ESM module loader is experimental.\n');
}));