• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import { spawnPromisified } from '../common/index.mjs';
2import { fixturesDir } from '../common/fixtures.mjs';
3import { match, notStrictEqual } from 'node:assert';
4import { execPath } from 'node:process';
5import { describe, it } from 'node:test';
6
7
8describe('ESM: module not found hint', { concurrency: true }, () => {
9  for (
10    const { input, expected }
11    of [
12      {
13        input: 'import "./print-error-message"',
14        // Did you mean to import ../print-error-message.js?
15        expected: / \.\.\/print-error-message\.js\?/,
16      },
17      {
18        input: 'import obj from "some_module/obj"',
19        expected: / some_module\/obj\.js\?/,
20      },
21    ]
22  ) it('should cite a variant form', async () => {
23    const { code, stderr } = await spawnPromisified(execPath, [
24      '--input-type=module',
25      '--eval',
26      input,
27    ], {
28      cwd: fixturesDir,
29    });
30
31    match(stderr, expected);
32    notStrictEqual(code, 0);
33  });
34});
35