mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
This commit fixes typos found in test files. PR-URL: https://github.com/nodejs/node/pull/42536 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
// Flags: --loader ./test/fixtures/es-module-loaders/hook-resolve-type.mjs
|
|
import { allowGlobals } from '../common/index.mjs';
|
|
import * as fixtures from '../common/fixtures.mjs';
|
|
import { strict as assert } from 'assert';
|
|
import * as fs from 'fs';
|
|
|
|
allowGlobals(global.getModuleTypeStats);
|
|
|
|
const basePath =
|
|
new URL('./node_modules/', import.meta.url);
|
|
|
|
const rel = (file) => new URL(file, basePath);
|
|
const createDir = (path) => {
|
|
if (!fs.existsSync(path)) {
|
|
fs.mkdirSync(path);
|
|
}
|
|
};
|
|
|
|
const moduleName = 'module-counter-by-type';
|
|
|
|
const moduleDir = rel(`${moduleName}`);
|
|
createDir(basePath);
|
|
createDir(moduleDir);
|
|
fs.cpSync(
|
|
fixtures.path('es-modules', moduleName),
|
|
moduleDir,
|
|
{ recursive: true }
|
|
);
|
|
|
|
const { importedESM: importedESMBefore,
|
|
importedCJS: importedCJSBefore } = global.getModuleTypeStats();
|
|
|
|
await import(`${moduleName}`).finally(() => {
|
|
fs.rmSync(basePath, { recursive: true, force: true });
|
|
});
|
|
|
|
const { importedESM: importedESMAfter,
|
|
importedCJS: importedCJSAfter } = global.getModuleTypeStats();
|
|
|
|
// Dynamic import above should increment ESM counter but not CJS counter
|
|
assert.strictEqual(importedESMBefore + 1, importedESMAfter);
|
|
assert.strictEqual(importedCJSBefore, importedCJSAfter);
|