Skip to content

test: add validation middleware tests (fixes #2019)#2170

Open
gavin913427-hash wants to merge 1 commit intoasyncapi:masterfrom
gavin913427-hash:feat/improve-middleware-test-coverage
Open

test: add validation middleware tests (fixes #2019)#2170
gavin913427-hash wants to merge 1 commit intoasyncapi:masterfrom
gavin913427-hash:feat/improve-middleware-test-coverage

Conversation

@gavin913427-hash
Copy link
Copy Markdown

What

Add tests for validation middleware to improve test coverage.

Why

The validation middleware (lib/apps/api/middlewares/validation.middleware.ts) had low test coverage. Many error-handling branches and async flows were not exercised.

How

  • Created test/unit/middlewares/validation.middleware.test.ts with 5 test cases
  • Tests condition-based pass-through
  • Tests unsupported path handling
  • Tests request body validation
  • Tests invalid body rejection
  • Tests document array handling

Changes

File Change
test/unit/middlewares/validation.middleware.test.ts NEW: 5 tests for validation middleware

Fixes #2019

Add tests for validation middleware covering:
- Condition-based pass-through
- Unsupported path handling
- Request body validation
- Invalid body rejection
- Document array handling

Improves test coverage for lib/apps/api/middlewares/validation.middleware.ts

Fixes asyncapi#2019
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 4, 2026

⚠️ No Changeset found

Latest commit: 7edf163

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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.

[TEST] : low coverage in lib/apps/api/middlewares

1 participant