Skip to content

Commit 25faa5c

Browse files
committed
Improves test
1 parent 918bb1d commit 25faa5c

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

test/parallel/test-require-package-map.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,6 @@ describe('CJS: --experimental-package-map', { concurrency: !process.env.TEST_PAR
8080
assert.strictEqual(status, 0, stderr);
8181
});
8282

83-
it('resolves from createRequire() paths with mixed separators', {
84-
skip: !common.isWindows && 'mixed path separators only need normalization on Windows',
85-
}, () => {
86-
const { status, stdout, stderr } = spawnSync(process.execPath, [
87-
'--no-warnings',
88-
'--experimental-package-map', packageMapPath,
89-
'-e',
90-
`const { createRequire } = require('node:module'); const req = createRequire(process.cwd() + '/index.js'); const dep = req('dep-a'); console.log(dep.default);`,
91-
], {
92-
cwd: fixtures.path('package-map/root'),
93-
encoding: 'utf8',
94-
});
95-
96-
assert.strictEqual(stderr, '');
97-
assert.match(stdout, /dep-a-value/);
98-
assert.strictEqual(status, 0, stderr);
99-
});
10083
});
10184

10285
describe('resolution boundaries', () => {
@@ -318,6 +301,22 @@ describe('CJS: --experimental-package-map', { concurrency: !process.env.TEST_PAR
318301
describe('longest path wins', () => {
319302
const longestPathMap = fixtures.path('package-map/package-map-longest-path.json');
320303

304+
it('resolves from createRequire() paths with mixed separators', () => {
305+
const { status, stdout, stderr } = spawnSync(process.execPath, [
306+
'--no-warnings',
307+
'--experimental-package-map', longestPathMap,
308+
'-e',
309+
`const { createRequire } = require('node:module'); const req = createRequire(process.cwd() + '/node_modules/inner/index.js'); const dep = req('dep-a'); console.log(dep.default);`,
310+
], {
311+
cwd: fixtures.path('package-map/root'),
312+
encoding: 'utf8',
313+
});
314+
315+
assert.strictEqual(stderr, '');
316+
assert.match(stdout, /dep-a-value/);
317+
assert.strictEqual(status, 0, stderr);
318+
});
319+
321320
it('resolves nested package using its own dependencies, not the parent', () => {
322321
// Inner lives at ./root/node_modules/inner which is inside root's
323322
// path (./root). The longest matching path should win, so code in

0 commit comments

Comments
 (0)