Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vitest|Storybook: Create communication channel to gather coverage information #28629

Closed
Tracked by #28608
valentinpalkovic opened this issue Jul 17, 2024 · 2 comments
Closed
Tracked by #28608

Comments

@valentinpalkovic
Copy link
Contributor

valentinpalkovic commented Jul 17, 2024

To provide real-time component coverage information in Storybook, we need to establish a communication channel between Vitest, the Storybook server, and the Storybook UI. This communication channel will facilitate the transfer of coverage data collected by Vitest to the Storybook UI, enabling developers to view real-time coverage updates as they work on their components and stories.

Tasks

Setup WebSocket Server

  • Integrate a WebSocket server within the Storybook server setup to handle incoming connections from Vitest and the Storybook UI.
  • Ensure the WebSocket server can handle multiple connections and broadcast messages to all connected clients.

Modify Vitest to Send Coverage Data

  • Implement functionality in Vitest to send coverage data to the WebSocket server after each test run.
  • Ensure the coverage data is sent in a structured format (e.g., JSON) that can be easily parsed by the Storybook UI.

Setup a WebSocket connection

  • Implement a WebSocket client in the Storybook UI that listens for coverage updates from the WebSocket server.

(Optional) Error Handling and Edge Cases

  • Implement robust error handling to manage connection issues and ensure reliable communication between Vitest, the Storybook server, and the Storybook UI.
  • Define fallback mechanisms to handle scenarios where the WebSocket connection is lost or coverage data is incomplete.

Acceptance Criteria

  • A WebSocket server is integrated into the Storybook server setup and can handle connections from Vitest and the Storybook UI.
  • Vitest is modified to send coverage data to the WebSocket server after each test run.
  • The Storybook UI is updated with a WebSocket client that listens for coverage updates and displays the coverage data in real-time.
  • Robust error handling is implemented to ensure reliable communication and handle edge cases gracefully.
  • Documentation is provided detailing the implementation steps and configuration required for the communication channel.
Copy link
Contributor

greptile-apps bot commented Jul 17, 2024

** Disclaimer** This information might be inaccurate, due to it being generated automatically
To create a communication channel for gathering coverage information between Vitest and Storybook, follow these steps:

  1. Define the Fix: Create a new file in /code/lib/cli/src/automigrate/fixes/ for the Vitest coverage communication channel.
import { dedent } from 'ts-dedent';
import chalk from 'chalk';
import { Fix } from '../types';

export const vitestCoverage: Fix<{}> = {
  id: 'vitest-coverage',
  versionRange: ['<8.0.0', '>=8.0.0'],

  async check({ mainConfig }) {
    // Implement check logic
    return {};
  },

  prompt() {
    return dedent`
      Would you like to set up a communication channel to gather coverage information from Vitest?
    `;
  },

  async run({ packageManager, dryRun, mainConfigPath, skipInstall }) {
    if (!dryRun) {
      // Implement run logic
    }
  },
};
  1. Update Main Config: Use updateMainConfig to modify the main configuration file as needed.

  2. Add Dependencies: Use packageManager.addDependencies to add any necessary dependencies for Vitest coverage.

Refer to vta.ts and new-frameworks.ts for examples of how to structure the prompt and gather necessary information.

References

/code/lib/cli/src/automigrate/fixes/vta.ts
/code/lib/cli/src/automigrate/fixes/new-frameworks.ts
/code/lib/cli/src/automigrate

About Greptile

This response provides a starting point for your research, not a precise solution.

Help us improve! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

Ask Greptile · Edit Issue Bot Settings

@valentinpalkovic
Copy link
Contributor Author

Completed, except of the optional requirement "(Optional) Error Handling and Edge Cases".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant