Skip to content

fix: suppress npm progress output in tests for hermeticity (fixes #2004)#2174

Open
gavin913427-hash wants to merge 1 commit intoasyncapi:masterfrom
gavin913427-hash:fix/test-hermeticity
Open

fix: suppress npm progress output in tests for hermeticity (fixes #2004)#2174
gavin913427-hash wants to merge 1 commit intoasyncapi:masterfrom
gavin913427-hash:fix/test-hermeticity

Conversation

@gavin913427-hash
Copy link
Copy Markdown

What does this PR do?

Makes integration tests hermetic by suppressing npm progress output that pollutes stdout and breaks assertions (fixes #2004)

Problem

Integration tests fail because some CLI commands trigger real npm dependency resolution during test execution. npm prints progress output (idealTree spinners, dependency logs) to stdout, which breaks tests that assert exact empty or fixed string output.

Solution

Added npm environment variables to test/helpers/init.js:

  • npm_config_loglevel=silent — suppresses npm log output
  • npm_config_progress=false — disables npm progress bars
  • NPM_CONFIG_LOGLEVEL=silent — uppercase variant for broader compatibility
  • NPM_CONFIG_PROGRESS=false — uppercase variant

This ensures all npm operations during tests run silently, preventing stdout pollution.

Why this approach

  • Minimal change: Only 6 lines added to a single file
  • No test rewrites needed: Existing assertions work as-is
  • Environment-independent: Works regardless of npm version, OS, or network conditions
  • Non-invasive: Doesn't affect the CLI's behavior in production

Related issue(s)

Fixes #2004

Checklist

  • Added npm environment variables to test init
  • Added changeset
  • No changes to CLI behavior

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 4, 2026

🦋 Changeset detected

Latest commit: 51af4c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

[BUG] npm test is non-hermetic: integration tests trigger real npm installs and fail due to stdout/stderr pollution

1 participant