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: Fix duplicate test.include patterns #30029

Merged
merged 4 commits into from
Dec 12, 2024

Conversation

JReinhold
Copy link
Contributor

@JReinhold JReinhold commented Dec 11, 2024

What I did

#29806 introduced a regression, where we wouldn't correctly remove any user-defined patterns in the Vitest workspace config, but just add our stories based on on top. That meant that if user's include patterns already included stories, they would be included and counted twice.

This fixes that, by removing the user's test.include config correctly.

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

  1. In the React kitchen sink:
  2. Run all tests from the Storybook UI, twice. See that it should report the correct number of tests (12 at the time of writing).
  3. Add back the test.include configuration that was removed here: https://github.com/storybookjs/storybook/pull/30029/files#diff-ac98573544572f4f674f737551c9bc27cd63113cc15d5b3fcd6f05a3f5ed62f3L13-L15
  4. Restart Storybook, run tests
  5. See a warning in the terminal with "Warning: Starting in Storybook 8.5.0-alpha.18, the "test.include" option in Vitest is discouraged..."
  6. Run tests twice again, and see that even with the bad include, tests are still counted correctly.

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.86 0%
initSize 133 MB 133 MB 0 B 2.49 0%
diffSize 55.3 MB 55.3 MB 0 B 2.64 0%
buildSize 6.87 MB 6.87 MB 0 B -2.01 0%
buildSbAddonsSize 1.51 MB 1.51 MB 0 B -2 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.86 MB 1.86 MB 0 B -2.38 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.57 MB 3.57 MB 0 B -2.01 0%
buildPreviewSize 3.3 MB 3.3 MB 0 B -2.38 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 8.4s 7.5s -903ms -0.68 -12%
generateTime 24.1s 20.3s -3s -765ms -0.39 -18.5%
initTime 15.5s 14.4s -1s -114ms -0.21 -7.7%
buildTime 10.3s 7.7s -2s -599ms -2.39 🔰-33.7%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5.2s 6.2s 1s 1.95 🔺16.4%
devManagerResponsive 3.9s 4s 168ms 0.9 4.1%
devManagerHeaderVisible 654ms 686ms 32ms 1.42 4.7%
devManagerIndexVisible 693ms 725ms 32ms 1.25 4.4%
devStoryVisibleUncached 2.1s 1.9s -225ms 0.22 -11.6%
devStoryVisible 694ms 723ms 29ms 1.24 4%
devAutodocsVisible 469ms 662ms 193ms 1.82 🔺29.2%
devMDXVisible 582ms 529ms -53ms -0.1 -10%
buildManagerHeaderVisible 728ms 556ms -172ms -0.34 -30.9%
buildManagerIndexVisible 741ms 635ms -106ms -0.44 -16.7%
buildStoryVisible 600ms 500ms -100ms -0.38 -20%
buildAutodocsVisible 512ms 435ms -77ms -0.35 -17.7%
buildMDXVisible 465ms 450ms -15ms 0.01 -3.3%

Greptile Summary

Fixed a regression in the Vitest workspace configuration where user-defined test patterns were causing duplicate test counts by properly handling the test.include configuration.

  • Modified code/addons/test/src/vitest-plugin/index.ts to clear user's test.include array when detected
  • Added warning message in console for deprecated test.include usage starting from v8.5.0-alpha.18
  • Removed explicit test.include patterns from test-storybooks/portable-stories-kitchen-sink/react/vitest.workspace.ts
  • Ensured backward compatibility while preventing duplicate story counting

Copy link

nx-cloud bot commented Dec 11, 2024

☁️ Nx Cloud Report

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

@JReinhold JReinhold marked this pull request as ready for review December 11, 2024 13:38
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.

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

code/addons/test/src/vitest-plugin/index.ts Show resolved Hide resolved
code/addons/test/src/vitest-plugin/index.ts Show resolved Hide resolved
code/addons/test/src/vitest-plugin/index.ts Show resolved Hide resolved
@JReinhold JReinhold merged commit 6e9fb74 into next Dec 12, 2024
55 of 58 checks passed
@JReinhold JReinhold deleted the jeppe/fix-duplicate-include branch December 12, 2024 09:11
@valentinpalkovic valentinpalkovic changed the title Vitest: Fix duplicate test.include patterns Addon Test: Fix duplicate test.include patterns Dec 13, 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.

2 participants