Skip to content

[FEATURE] <description>Add automated tests for the WebSocket server generated by the Node.js WS template #439

@sauraviiitk

Description

@sauraviiitk

Why do we need this improvement?

The Node.js WebSocket template currently generates a functional WebSocket server, but there are no automated tests validating the generated output. This means that any change to the template can unintentionally break the generated server without being detected early.

Since this repository provides a code generation template, users rely on the generated code to work correctly out of the box. Without automated tests, regressions may only be discovered after users manually generate and run the project, leading to a poor developer experience and increased maintenance effort.

How will this change help?

This improvement will:

  • Ensure the generated WebSocket server starts correctly
  • Verify that WebSocket clients can successfully connect
  • Validate that messages defined in the AsyncAPI document are handled as expected
  • Ensure invalid or malformed messages are handled gracefully without crashing the server
    Overall, this will increase confidence in the template, reduce regressions, and improve reliability for both users and maintainers.

Screenshots

No response

How could it be implemented/designed?

A possible implementation approach:

  • Create a minimal AsyncAPI document as a test fixture
  • Generate a WebSocket server from the template using this document
  • Start the generated server programmatically during tests
  • Use a WebSocket client (e.g., ws) to simulate client connections
  • Add tests for:
  1. Server startup
  2. Client connection success
  3. Handling of valid messages
  4. Graceful handling of invalid messages
  • Integrate these tests into the existing test or CI workflow

This approach keeps the scope focused while providing meaningful coverage of the generated output.

🚧 Breaking changes

Yes

👀 Have you checked for similar open issues?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions