asyncapi / asyncapi/website

[Test]: improve reliability and correctness of serve-definitions tests

Open Beginner friendly
#5,075 4 comments 0 reactions 0 assignees View on GitHub
stale triaged
Dominant language
TypeScript
Stars
716
Forks
1.2k
Avg merge
1d 12h
Merged PRs (30d)
35

Description

While reviewing serve-definition.test.ts, several test-quality issues were found that can lead to false positives, brittle tests, and reduced maintainability.
These are not breaking bugs but should be addressed to improve test correctness.

1:-Manual metricCalls increment bypasses real behavior

Image

Here, metricCalls is incremented inside the test itself, not via the mocked metricURL request handled in ` mf.mock`.

1:-Shared mutable state across tests

Image

This variable is shared across multiple ` Deno.test `blocks and reused in different contexts.
This creates:-
Implicit coupling between tests and Dependence on execution order or correct manual resets which reduces the tests Isolation.

3:-Unused test data (mockParam)

Image

Here,` mockParam` is never used which increases noise and makes the test harder to reason about.

I am interested in solving this.

Contributor guide

Open the contributing guide

Research direction

Read serve-definition.test.ts, focusing on the Deno.test blocks, metricCalls, mf.mock, and the unused mockParam shown in the issue. Run the serve-definitions tests first; done means the tests rely on the mocked metric request, avoid shared mutable state and manual resets, remove unused data, and retain reliable assertions.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.