test: add test for install summary without updated manifest log

Add a reporter test verifying that when packageManifestLogger only emits
the initial manifest (as happens during dry runs), the summary correctly
shows only root-level changes without false dependency type diffs.

Also add changeset for the install summary fix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Zoltan Kochan
2026-03-15 22:08:09 +01:00
parent e0a38c8879
commit efb341bd71
2 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/resolve-dependencies": patch
"pnpm": patch
---
Fixed the install summary in workspaces by setting recursive config before reporter initialization and skipping manifest logging during dry runs.

View File

@@ -38,6 +38,54 @@ const h1 = chalk.cyanBright
const EOL = '\n'
test('does not show false dependency changes when updated manifest is not logged', async () => {
const prefix = '/home/jane/project'
const output$ = toOutput$({
context: {
argv: ['install'],
config: { dir: prefix } as Config,
},
streamParser: createStreamParser(),
})
// During a dry run, only the initial manifest is logged (no updated manifest).
// The summary should only show root-level added packages, not false dependency type changes.
packageManifestLogger.debug({
initial: {
name: 'foo',
version: '1.0.0',
dependencies: {
'is-positive': '^1.0.0',
},
devDependencies: {
'is-negative': '^1.0.0',
},
},
prefix,
})
rootLogger.debug({
added: {
dependencyType: 'prod',
id: 'registry.npmjs.org/is-positive/1.0.0',
name: 'is-positive',
realName: 'is-positive',
version: '1.0.0',
},
prefix,
})
summaryLogger.debug({ prefix })
expect.assertions(1)
const output = await firstValueFrom(output$.pipe(take(1), map(normalizeNewline)))
// Should only show the added package, not re-list existing deps as added/removed
expect(output).toBe(EOL + `\
${h1('dependencies:')}
${ADD} is-positive ${versionColor('1.0.0')}
`)
})
test('prints summary (of current package only)', async () => {
const prefix = '/home/jane/project'
const output$ = toOutput$({