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: Automatically load before all #30584

Open
wants to merge 4 commits into
base: next
Choose a base branch
from

Conversation

kasperpeulen
Copy link
Contributor

@kasperpeulen kasperpeulen commented Feb 19, 2025

Closes #

What I did

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 79.7 MB 79.7 MB 0 B -1.94 0%
initSize 79.7 MB 79.7 MB 0 B -1.94 0%
diffSize 97 B 97 B 0 B - 0%
buildSize 7.29 MB 7.29 MB -84 B -1.49 0%
buildSbAddonsSize 1.9 MB 1.9 MB 0 B - 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.88 MB 1.88 MB -7 B 0.9 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.97 MB 3.97 MB -7 B 0.9 0%
buildPreviewSize 3.32 MB 3.32 MB -77 B -1.51 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.5s 21.6s 14s 1.24 🔺65.2%
generateTime 24.7s 19.2s -5s -577ms -0.45 -29%
initTime 4.5s 4.5s 0ms -0.5 0%
buildTime 9.2s 8.3s -975ms -1.1 -11.7%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5.3s 5.5s 243ms 0.02 4.3%
devManagerResponsive 5.1s 5.3s 269ms 0.09 5%
devManagerHeaderVisible 778ms 744ms -34ms -0.36 -4.6%
devManagerIndexVisible 781ms 759ms -22ms -0.55 -2.9%
devStoryVisibleUncached 1.6s 1.8s 195ms 0 10.6%
devStoryVisible 811ms 776ms -35ms -0.8 -4.5%
devAutodocsVisible 754ms 764ms 10ms -0.18 1.3%
devMDXVisible 756ms 765ms 9ms 0.37 1.2%
buildManagerHeaderVisible 669ms 992ms 323ms 1.07 32.6%
buildManagerIndexVisible 737ms 1s 350ms 1.24 🔺32.2%
buildStoryVisible 653ms 913ms 260ms 0.8 28.5%
buildAutodocsVisible 549ms 774ms 225ms 1.16 29.1%
buildMDXVisible 546ms 704ms 158ms 0.94 22.4%

Greptile Summary

This PR enables the beforeAll lifecycle hook in the Vitest setup file for Storybook's test addon, ensuring proper initialization of global project annotations before test execution.

  • Added support for beforeAll hook in code/addons/test/src/vitest-plugin/setup-file.ts
  • Uncommented code that was previously marked with "Enable this in 9.0" comment
  • Checks for existence of globalThis.globalProjectAnnotations and calls its beforeAll method if available
  • Aligns with documented preview lifecycle hooks in Storybook
  • Ensures proper initialization before running test suites

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

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

@kasperpeulen kasperpeulen changed the base branch from next to next-9.0 February 19, 2025 15:19
Copy link
Contributor

github-actions bot commented Feb 19, 2025

Fails
🚫 PR is marked with "BREAKING CHANGE" label.

Generated by 🚫 dangerJS against 345cf3d

Copy link

nx-cloud bot commented Feb 19, 2025

View your CI Pipeline Execution ↗ for commit 345cf3d.

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 58s View ↗

☁️ Nx Cloud last updated this comment at 2025-02-26 10:30:02 UTC

@kasperpeulen kasperpeulen changed the base branch from next-9.0 to next February 19, 2025 15:21
@kasperpeulen kasperpeulen marked this pull request as draft February 19, 2025 15:21
@kasperpeulen kasperpeulen marked this pull request as ready for review February 25, 2025 11:09
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

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

Comment on lines +38 to +42
beforeAll(() => {
if (globalThis.globalProjectAnnotations) {
return globalThis.globalProjectAnnotations.beforeAll();
}
});
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to pass down the context (test suite metadata)?

Suggested change
beforeAll(() => {
if (globalThis.globalProjectAnnotations) {
return globalThis.globalProjectAnnotations.beforeAll();
}
});
beforeAll((suite) => {
if (globalThis.globalProjectAnnotations) {
return globalThis.globalProjectAnnotations.beforeAll(suite);
}
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

storybook's beforeAll doesn't accepts it

@vanessayuenn vanessayuenn added this to the 9.0 milestone Feb 26, 2025
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.

4 participants