storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
83.93k stars 9.21k forks source link

Vitest: Create "Component Coverage" per story file #28628

Closed valentinpalkovic closed 2 weeks ago

valentinpalkovic commented 1 month ago

We need to implement a mechanism in Vitest to generate coverage reports for each story file. This task focuses on collecting coverage data for all affected files when a story file is executed, and outputting the data in a parseable format. This will serve as the foundation for integrating coverage data into the Storybook UI or server at a later stage.

Tasks:

Configure Vitest for Coverage Reporting:

Generate Coverage Reports:

Modify the Vitest configuration to generate coverage reports in a parseable format (e.g., JSON, LCOV). Ensure the reports include detailed coverage information for all affected files related to the story file being tested.

(Optional) Save Coverage Data:

Implement a mechanism to save the generated coverage reports in a structured format in a predefined directory. Ensure the saved data is organized and accessible for later use.

Documentation:

Document the process and configuration steps required to generate coverage reports with Vitest. Provide examples of the generated coverage data format for reference.

Acceptance Criteria:

greptile-apps[bot] commented 1 month ago

Disclaimer This information might be inaccurate, due to it being generated automatically

  1. Modify summarizeIndex in /code/core/src/core-server/utils/summarizeIndex.test.ts to include component coverage data.
  2. Create a new utility function similar to extractComponentDescription in /code/renderers/svelte/src/docs/extractComponentDescription.test.ts to extract component coverage information.
  3. Update CLI tools in /code/lib/cli-storybook and /code/lib/cli-sb to support the new component coverage feature.

References

/code/core/src/core-server/utils/summarizeIndex.test.ts /code/renderers/svelte/src/docs/extractComponentDescription.test.ts /code/lib/cli-storybook /code/lib/cli-sb

#### 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](https://app.greptile.com/chat/github/storybookjs/storybook/next) · [Edit Issue Bot Settings](https://app.greptile.com/apps/github)
valentinpalkovic commented 2 weeks ago

Completed. Except of the optional "(Optional) Save Coverage Data" requirement.