node/test/es-module/test-esm-symlink-main.js
Antoine du Hamel 5f77aebdfb
test: ensure assertions are reachable in test/es-module
PR-URL: https://github.com/nodejs/node/pull/60501
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2025-11-07 09:24:01 +01:00

26 lines
712 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const path = require('path');
const { spawn } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fs = require('fs');
tmpdir.refresh();
const realPath = path.resolve(__dirname, '../fixtures/es-modules/symlink.mjs');
const symlinkPath = tmpdir.resolve('symlink.mjs');
try {
fs.symlinkSync(realPath, symlinkPath);
} catch (err) {
if (err.code !== 'EPERM') throw err;
common.skip('insufficient privileges for symlinks');
}
spawn(process.execPath,
['--preserve-symlinks', symlinkPath],
{ stdio: 'inherit' }).on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0);
}));