From 5ffaa8aaba7678637913908fab0069a8dc14fece Mon Sep 17 00:00:00 2001 From: Wes Todd Date: Fri, 12 Dec 2025 14:55:07 -0600 Subject: [PATCH 1/2] fix(test): added test for null private field --- test/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/index.js b/test/index.js index ea92a9f..7c61053 100644 --- a/test/index.js +++ b/test/index.js @@ -212,6 +212,16 @@ suite('create-package-json', () => { assert.strictEqual(pkg.private, true); }); + // Remove null/undefined keys + test('remove null/undefined keys', async () => { + await fix.setup(); + const pkg = await createPackageJson({ + private: null + }); + + assert.strictEqual(pkg.private, undefined); + }); + test('scaffold scripts', async () => { await fix.setup(); const pkg = await createPackageJson(); @@ -276,10 +286,10 @@ suite('create-package-json', () => { assert.deepStrictEqual(pkg.scripts, npmInitPkg.scripts); assert.deepStrictEqual(pkg.keywords, npmInitPkg.keywords); assert.strictEqual(pkg.license, npmInitPkg.license); + assert.strictEqual(pkg.type, npmInitPkg.type); // Should be different assert.notStrictEqual(pkg.author, npmInitPkg.author, JSON.stringify([pkg.author, npmInitPkg.author])); - assert.notStrictEqual(pkg.type, npmInitPkg.type, JSON.stringify([pkg.type, npmInitPkg.type])); }); }); }); From 1ad72036584bfeb22fe5d017c9a3fe91546cdf25 Mon Sep 17 00:00:00 2001 From: Wes Todd Date: Mon, 15 Dec 2025 12:49:38 -0600 Subject: [PATCH 2/2] fix(test): fixed npm parity test --- test/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/index.js b/test/index.js index 7c61053..b14d1e4 100644 --- a/test/index.js +++ b/test/index.js @@ -286,7 +286,13 @@ suite('create-package-json', () => { assert.deepStrictEqual(pkg.scripts, npmInitPkg.scripts); assert.deepStrictEqual(pkg.keywords, npmInitPkg.keywords); assert.strictEqual(pkg.license, npmInitPkg.license); - assert.strictEqual(pkg.type, npmInitPkg.type); + + // Handle different behavior for node versions + if (parseInt(process.version.split(/v|\./)[1], 10) < 24) { + assert.notStrictEqual(pkg.type, npmInitPkg.type); + } else { + assert.strictEqual(pkg.type, npmInitPkg.type); + } // Should be different assert.notStrictEqual(pkg.author, npmInitPkg.author, JSON.stringify([pkg.author, npmInitPkg.author]));