summaryrefslogtreecommitdiff
path: root/test/es-module/test-esm-no-extension.js
blob: 3e9ffb2bbca8dfe145ae26ce7186dc568fe0f617 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'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/noext-esm');

// Run a module that does not have extension
// This is to ensure the --entry-type works as expected

const child = spawn(process.execPath, [
  '--experimental-modules',
  '--entry-type=module',
  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');
}));