Skip to content

test: add integration tests for optimize --output=overwrite (fixes #1933)#2173

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

test: add integration tests for optimize --output=overwrite (fixes #1933)#2173
gavin913427-hash wants to merge 1 commit intoasyncapi:masterfrom
gavin913427-hash:fix/optimize-overwrite-test

Conversation

@gavin913427-hash
Copy link
Copy Markdown

What does this PR do?

Adds missing integration test coverage for the asyncapi optimize command when using the --output=overwrite flag with --no-tty (fixes #1933)

Changes

Added two new test cases to test/integration/optimize.test.ts:

  1. YAML overwrite test: Copies an unoptimized YAML fixture to a temp file, runs optimize --no-tty --output=overwrite, verifies:

    • Output message confirms the original file was updated
    • The overwritten file still contains valid AsyncAPI content (asyncapi: 2.0.0)
    • No stderr errors
  2. JSON overwrite test: Same flow with a JSON fixture, verifying JSON output format is preserved after overwrite

Why this matters

The --output=overwrite path was previously untested, meaning regressions in file-overwriting behavior could go undetected.

Related issue(s)

Fixes #1933

Checklist

  • Tests added for --output=overwrite with YAML input
  • Tests added for --output=overwrite with JSON input
  • Tests clean up temp files after running
  • Added changeset

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 4, 2026

🦋 Changeset detected

Latest commit: da9e237

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] optimize command: missing test coverage for --output=overwrite

1 participant