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: Refactor test addon to include stories automatically #29367

Draft
wants to merge 1 commit into
base: unified-ui-testing
Choose a base branch
from

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Oct 16, 2024

Closes #

What I did

This PR introduces a change in the Vitest plugin where it leverages the stories field of main.js to transform into an array of globs for vitest, and adds that automatically as config.test.include.

I tested this locally in the monorepo's Storybook and it worked without issues. Adding extra include or exclude paths in the vitest config will work as expected.

Things to note/discuss:

  1. Storybook's internal glob matching mechanism (picomatch) might not be the same as Vitest, so not all types of glob users use might be compatible.
  2. What do we do with globs that include mdx? Do we just filter them out? But what about single, complex globs that try to include everything, including mdx? if we just filtered them, we would be filtering stories as well. In such cases we'd have to manipulate the globs instead. The fact we are not filtering MDX is what is causing the unit tests to fail in this PR
  3. The story globs calculation needs to assume a working directory, which might be incorrect in monorepos or other cases. The solution might be too naive right now

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 2.56 kB 0.54 0%
initSize 147 MB 147 MB 5.5 kB -0.73 0%
diffSize 68.3 MB 68.3 MB 2.94 kB -0.73 0%
buildSize 7.1 MB 7.1 MB 0 B -0.49 0%
buildSbAddonsSize 1.79 MB 1.79 MB 0 B -0.52 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.85 MB 1.85 MB 0 B -0.54 0%
buildSbPreviewSize 271 kB 271 kB 0 B -0.56 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.1 MB 4.1 MB 0 B -0.54 0%
buildPreviewSize 3 MB 3 MB 0 B 0.74 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 22.6s 5.9s -16s -689ms -1.49 🔰-281.4%
generateTime 18.3s 19.9s 1.6s -0.66 8.1%
initTime 11.8s 13.8s 2s -0.76 14.6%
buildTime 10.5s 7.9s -2s -585ms -1.38 🔰-32.5%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5.5s 6.5s 998ms 0.35 15.1%
devManagerResponsive 3.7s 4.2s 510ms 0.31 11.9%
devManagerHeaderVisible 561ms 634ms 73ms 0.75 11.5%
devManagerIndexVisible 589ms 677ms 88ms 0.89 13%
devStoryVisibleUncached 911ms 1.1s 252ms 0.61 21.7%
devStoryVisible 587ms 676ms 89ms 0.88 13.2%
devAutodocsVisible 510ms 627ms 117ms 1.36 🔺18.7%
devMDXVisible 556ms 540ms -16ms 0.19 -3%
buildManagerHeaderVisible 516ms 583ms 67ms 0.04 11.5%
buildManagerIndexVisible 588ms 616ms 28ms 0.11 4.5%
buildStoryVisible 589ms 617ms 28ms -0.13 4.5%
buildAutodocsVisible 524ms 572ms 48ms 0.79 8.4%
buildMDXVisible 496ms 585ms 89ms 0.5 15.2%

Copy link

nx-cloud bot commented Oct 16, 2024

☁️ Nx Cloud Report

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

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.

2 participants