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

Core: Boot Vitest runner when hovering the Testing Module #29387

Open
wants to merge 3 commits into
base: unified-ui-testing
Choose a base branch
from

Conversation

ghengeveld
Copy link
Member

@ghengeveld ghengeveld commented Oct 17, 2024

Adds a new TESTING_MODULE_BOOT_REQUEST event which is emitted when hovering the Testing Module. The Vitest manager is booted when this event fires, so that it's ready when a test run is started. This saves about 1.5-2 seconds on my Macbook Pro M1.

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 78.7 MB 78.7 MB 10.6 kB 2.84 0%
initSize 147 MB 147 MB 12.8 kB -0.2 0%
diffSize 68.3 MB 68.3 MB 2.19 kB -0.21 0%
buildSize 7.1 MB 7.1 MB 623 B 0.45 0%
buildSbAddonsSize 1.79 MB 1.79 MB 158 B 0.85 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.85 MB 1.85 MB 328 B 0.39 0%
buildSbPreviewSize 271 kB 271 kB 137 B 11.47 0.1%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.1 MB 4.1 MB 623 B 0.85 0%
buildPreviewSize 3 MB 3 MB 0 B 0.26 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 19.3s 18s -1s -288ms 0.74 -7.1%
generateTime 20.1s 21.5s 1.4s -0.28 6.5%
initTime 14s 13.4s -569ms -0.71 -4.2%
buildTime 8.5s 8s -457ms -1.16 -5.7%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5.6s 6s 362ms -0.43 6%
devManagerResponsive 3.8s 4.1s 276ms 0.33 6.7%
devManagerHeaderVisible 513ms 654ms 141ms 0.8 21.6%
devManagerIndexVisible 545ms 695ms 150ms 0.91 21.6%
devStoryVisibleUncached 926ms 1.3s 398ms 2.77 🔺30.1%
devStoryVisible 546ms 696ms 150ms 0.93 21.6%
devAutodocsVisible 519ms 619ms 100ms 0.93 16.2%
devMDXVisible 453ms 551ms 98ms 0.56 17.8%
buildManagerHeaderVisible 508ms 513ms 5ms -0.92 1%
buildManagerIndexVisible 568ms 551ms -17ms -0.92 -3.1%
buildStoryVisible 569ms 552ms -17ms -1.07 -3.1%
buildAutodocsVisible 500ms 473ms -27ms -1.14 -5.7%
buildMDXVisible 449ms 511ms 62ms -0.35 12.1%

Greptile Summary

This pull request introduces a new event TESTING_MODULE_BOOT_REQUEST to improve the performance of the Vitest runner in Storybook. The key changes include:

  • Added TESTING_MODULE_BOOT_REQUEST event to code/core/src/core-events/index.ts
  • Implemented event listener for TESTING_MODULE_BOOT_REQUEST in code/addons/test/src/preset.ts
  • Integrated bootTestProviders function in SidebarBottom component to emit the new event on hover
  • Updated code/core/src/manager/globals/exports.ts to include the new event in globalized dependencies
  • Modified execute function in test preset to accept an optional eventName parameter

These changes aim to preemptively boot the Vitest runner when hovering over the Testing Module, potentially saving 1.5-2 seconds of loading time.

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.

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

code/addons/test/src/preset.ts Show resolved Hide resolved
Copy link

nx-cloud bot commented Oct 17, 2024

☁️ Nx Cloud Report

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

@valentinpalkovic valentinpalkovic left a comment

Choose a reason for hiding this comment

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

Rebased, since tests were failing. Otherwise, LGTM

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