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 Vitest: Fix error message logic in set up file #28906

Merged
merged 3 commits into from
Aug 16, 2024

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Aug 16, 2024

Closes #28903

What I did

Before, the set up file was only overwriting the error message of the last failure if multiple stories failed. Now it is attached per test run, so it works in all occasions.

I also added a small optimization on the channel mocks

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/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 76.3 MB 76.3 MB 0 B 0.64 0%
initSize 169 MB 169 MB 0 B 1.38 0%
diffSize 92.6 MB 92.6 MB 0 B 1.38 0%
buildSize 7.46 MB 7.46 MB 0 B 1.36 0%
buildSbAddonsSize 1.61 MB 1.61 MB 0 B 1.42 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 2.3 MB 2.3 MB 0 B 1.34 0%
buildSbPreviewSize 351 kB 351 kB 0 B -0.52 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.46 MB 4.46 MB 0 B 1.37 0%
buildPreviewSize 3 MB 3 MB 0 B 1.36 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 14s 25.1s 11s 1.33 🔺43.9%
generateTime 22.1s 18.3s -3s -811ms -1.03 -20.8%
initTime 20.6s 16.1s -4s -500ms -0.64 -27.9%
buildTime 11.7s 13.1s 1.3s 0.58 10.2%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 7.4s 7.3s -89ms -0.36 -1.2%
devManagerResponsive 4.8s 4.7s -89ms -0.21 -1.9%
devManagerHeaderVisible 783ms 763ms -20ms -0.51 -2.6%
devManagerIndexVisible 832ms 810ms -22ms -0.39 -2.7%
devStoryVisibleUncached 1.3s 1.2s -85ms -0.27 -6.6%
devStoryVisible 834ms 808ms -26ms -0.52 -3.2%
devAutodocsVisible 773ms 677ms -96ms -0.61 -14.2%
devMDXVisible 743ms 723ms -20ms -0.15 -2.8%
buildManagerHeaderVisible 783ms 711ms -72ms -0.33 -10.1%
buildManagerIndexVisible 788ms 712ms -76ms -0.37 -10.7%
buildStoryVisible 822ms 745ms -77ms -0.46 -10.3%
buildAutodocsVisible 642ms 719ms 77ms 0.43 10.7%
buildMDXVisible 651ms 603ms -48ms -0.7 -8%

Greptile Summary

This PR improves error handling and test coverage for the Storybook Vitest addon, focusing on more accurate error reporting and expanded test inclusion for addons.

  • Modified code/addons/vitest/src/plugin/setup-file.ts to use afterEach hook for more timely error reporting
  • Updated code/.storybook/vitest.config.ts to include all addon stories in testing
  • Enhanced HighlightElement.stories.tsx with waitFor function for improved test reliability
  • Changed storybook:vitest script in package.json to use yarn test:watch for continuous testing

Copy link

nx-cloud bot commented Aug 16, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 53d295d. 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

4 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@@ -33,7 +33,7 @@ export default mergeConfig(
include: [
// TODO: test all core and addon stories later
// './core/**/components/**/*.{story,stories}.?(c|m)[jt]s?(x)',
'../addons/interactions/src/**/*.{story,stories}.?(c|m)[jt]s?(x)',
'../addons/**/src/**/*.{story,stories}.?(c|m)[jt]s?(x)',
Copy link
Contributor

Choose a reason for hiding this comment

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

All of them work now ?!?

Copy link
Member Author

Choose a reason for hiding this comment

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

The addons, yes! There was a flake but I fixed it.
Most of the problems come from the other part (core) which is not enabled yet

afterAll((suite) => {
suite.tasks.forEach(modifyErrorMessage);
});
afterEach(modifyErrorMessage);
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, we don't need the meta anymore, because the story.id is available on the afterEach context.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could refactor this function to use story from context, but we should keep meta.storyId mutation in the file transformation because that is what goes in the json reports (and not the test context)

Copy link
Contributor

Choose a reason for hiding this comment

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

I see

Copy link
Contributor

@kasperpeulen kasperpeulen left a comment

Choose a reason for hiding this comment

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

LGTM

@yannbf yannbf merged commit b1b2c6b into next Aug 16, 2024
57 of 58 checks passed
@yannbf yannbf deleted the yann/fix-setup-file-message branch August 16, 2024 10:56
@github-actions github-actions bot mentioned this pull request Aug 16, 2024
9 tasks
@shilman shilman changed the title Vitest Addon: Fix error message logic in set up file Addon Vitest: Fix error message logic in set up file Aug 17, 2024
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.

Vitest addon: Fix error message reporting
2 participants