mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
test: add case for unrecognised fields within pjson "exports"
PR-URL: https://github.com/nodejs/node/pull/57026 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
committed by
James M Snell
parent
a613f2f312
commit
61a57f7761
0
test/fixtures/packages/unrecognised-export-keys/index.js
vendored
Normal file
0
test/fixtures/packages/unrecognised-export-keys/index.js
vendored
Normal file
10
test/fixtures/packages/unrecognised-export-keys/package.json
vendored
Normal file
10
test/fixtures/packages/unrecognised-export-keys/package.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "pkg-with-unrecognised-export-keys",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./index.js",
|
||||
"FtLcAG": "./whatever.ext",
|
||||
"types": "./index.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,4 +189,19 @@ describe('findPackageJSON', () => { // Throws when no arguments are provided
|
||||
assert.ok(stdout.includes(foundPjsonPath), stdout);
|
||||
assert.strictEqual(code, 0);
|
||||
});
|
||||
|
||||
it('should work when unrecognised keys are specified within the export', async () => {
|
||||
const specifierBase = './packages/unrecognised-export-keys';
|
||||
const target = fixtures.fileURL(specifierBase, 'index.js');
|
||||
const foundPjsonPath = path.toNamespacedPath(fixtures.path(specifierBase, 'package.json'));
|
||||
|
||||
const { code, stderr, stdout } = await common.spawnPromisified(process.execPath, [
|
||||
'--print',
|
||||
`require("node:module").findPackageJSON(${JSON.stringify(target)})`,
|
||||
]);
|
||||
|
||||
assert.strictEqual(stderr, '');
|
||||
assert.ok(stdout.includes(foundPjsonPath), stdout);
|
||||
assert.strictEqual(code, 0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user