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:
Jacob Smith authored and James M Snell committed 2025-02-15 11:45:13 -08:00
1 parent a613f2f312
commit 61a57f7761
3 files changed
+25

No files matched your search

Whitespace-only changes.
@@ -0,0 +1,10 @@
{
"name": "pkg-with-unrecognised-export-keys",
"exports": {
".": {
"default": "./index.js",
"FtLcAG": "./whatever.ext",
"types": "./index.d.ts"
}
}
}
+15
View File
@@ -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);
});
});