summaryrefslogtreecommitdiff
path: root/test/parallel/test-module-main-fail.js
blob: 2b6f188dd4cbeeb5e826c1c94d138ad2f1cbf6e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';
require('../common');
const assert = require('assert');
const { execFileSync } = require('child_process');

const entryPoints = ['iDoNotExist', 'iDoNotExist.js', 'iDoNotExist.mjs'];
const node = process.argv[0];

for (const entryPoint of entryPoints) {
  try {
    execFileSync(node, [entryPoint], { stdio: 'pipe' });
  } catch (e) {
    const error = e.toString();
    assert.match(error, /MODULE_NOT_FOUND/);
    assert.match(error, /Cannot find module/);
    assert(error.includes(entryPoint));
    continue;
  }
  assert.fail('Executing node with inexistent entry point should ' +
              `fail. Entry point: ${entryPoint}`);
}