Skip to content

[BUG] :Potential test isolation issue due to shared AsyncAPI Parser instance and parsed document across helper tests #1927

@SHUBHANSHU602

Description

@SHUBHANSHU602

Describe the bug.

While reviewing the integration tests under packages/helpers/test, I noticed that multiple test suites share a single AsyncAPI Parser instance and a single parsed AsyncAPI document via beforeAll.

Examples include (but are not limited to):

bindings.test.js discriminators.test.js operations.test.js servers.test.js

Current Behavior

Parser is a stateful class.
The parsed AsyncAPI document exposes mutable collections (channels, operations, messages).
Sharing a single parser instance and parsed document across tests can introduce:
State leakage between tests
Order-dependent behavior
Fragility when tests are run in parallel or when new tests are added

Image

There is already an explicit comment in bindings.test.js indicating that shared state must be preserved:

Expected behavior

Each test suite (or test case) should be fully isolated, meaning:

Tests should not depend on shared parser state or shared parsed documents.
Mutations or derived data in one test should not affect other tests.
Test outcomes should be deterministic regardless of execution order or parallelization.

Suggested direction

To improve isolation and long-term stability, it may be preferable to:

Instantiate a new Parser per test suite or per test, and/or
Parse the AsyncAPI document in a more isolated scope instead of sharing it globally via beforeAll.

Screenshots

Image

How to Reproduce

Clone the repo
visit:-generator\packages\helpers\test
Analyse:-
bindings.test.js discriminators.test.js operations.test.js servers.test.js

🖥️ Device Information [optional]

Operating System :-Brave
Browser: Brave

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions