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

Addon Test: Improve error message on missing coverage package #30088

Merged
merged 3 commits into from
Dec 17, 2024

Conversation

JReinhold
Copy link
Contributor

@JReinhold JReinhold commented Dec 17, 2024

Closes #

What I did

Changed the error handling for coverage initialisation, to also catch an internal Vitest error that would sometimes be thrown when the coverage package was missing.

It now shows:

Screen Shot 2024-12-17 at 14 08 06 PM
Screen Shot 2024-12-17 at 14 07 25 PM

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.7 MB 77.7 MB 0 B 0.53 0%
initSize 136 MB 136 MB 0 B 0.23 0%
diffSize 58.4 MB 58.4 MB 0 B 0.23 0%
buildSize 7.24 MB 7.24 MB 0 B 1.95 0%
buildSbAddonsSize 1.88 MB 1.88 MB 0 B - 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.86 MB 1.86 MB 0 B 2.58 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.93 MB 3.93 MB 0 B 2.58 0%
buildPreviewSize 3.3 MB 3.3 MB 0 B -0.95 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 7.3s 6.7s -618ms -0.91 -9.2%
generateTime 20.7s 19.4s -1s -333ms -0.73 -6.9%
initTime 14.3s 13.5s -798ms -0.56 -5.9%
buildTime 11.8s 8.9s -2s -836ms -0.68 -31.5%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5.5s 5s -423ms 0.01 -8.3%
devManagerResponsive 4.1s 3.8s -257ms 0.12 -6.7%
devManagerHeaderVisible 643ms 628ms -15ms -0.01 -2.4%
devManagerIndexVisible 676ms 700ms 24ms 0.34 3.4%
devStoryVisibleUncached 1.8s 1.7s -143ms -0.2 -8.1%
devStoryVisible 674ms 697ms 23ms 0.29 3.3%
devAutodocsVisible 544ms 550ms 6ms 0 1.1%
devMDXVisible 518ms 532ms 14ms -0.24 2.6%
buildManagerHeaderVisible 619ms 599ms -20ms -0.28 -3.3%
buildManagerIndexVisible 704ms 682ms -22ms -0.39 -3.2%
buildStoryVisible 579ms 561ms -18ms -0.23 -3.2%
buildAutodocsVisible 446ms 479ms 33ms 0.32 6.9%
buildMDXVisible 439ms 488ms 49ms 0.26 10%

Greptile Summary

Based on the provided files and PR information, I'll create a concise summary of the changes:

Improved error handling for missing Vitest coverage packages by adding better detection and more informative error messages.

  • Added detection for TypeError when coverage packages are missing in vitest-manager.ts
  • Enhanced error message to specify which coverage package (@vitest/coverage-v8 or @vitest/coverage-istanbul) needs to be installed
  • Moved detailed error handling from test-manager.ts to vitest-manager.ts for better organization
  • Added early return after error reporting to prevent further execution
  • Simplified error reporting structure in TestManager class

const isV8 = e.message?.includes('@vitest/coverage-v8');
const isIstanbul = e.message?.includes('@vitest/coverage-istanbul');

if (e.message?.includes('Error: Failed to load url') && (isIstanbul || isV8)) {
const coveragePackage = isIstanbul ? 'coverage-istanbul' : 'coverage-v8';
e.message = `Please install the @vitest/${coveragePackage} package to run with coverage`;
}
this.reportFatalError('Failed to change coverage mode', e);
this.reportFatalError('Failed to change coverage configuration', e);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this case would already be handled within the Vitest Manager, so it doesn't make sense to try and handle it here too.

@JReinhold JReinhold marked this pull request as ready for review December 17, 2024 13:19
Copy link

nx-cloud bot commented Dec 17, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit d51634e. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@JReinhold JReinhold changed the title VItest: Improve error message on missing coverage package Vitest: Improve error message on missing coverage package Dec 17, 2024
@JReinhold JReinhold merged commit ba24c93 into next Dec 17, 2024
59 checks passed
@JReinhold JReinhold deleted the jeppe/improve-coverage-error branch December 17, 2024 20:33
@github-actions github-actions bot mentioned this pull request Dec 17, 2024
7 tasks
@shilman shilman changed the title Vitest: Improve error message on missing coverage package Addon Test: Improve error message on missing coverage package Dec 18, 2024
@github-actions github-actions bot mentioned this pull request Dec 18, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants