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 tests potentially not existing in non-isolate mode #28993

Merged
merged 2 commits into from
Aug 28, 2024

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Aug 28, 2024

Closes #

What I did

This PR fixes an issue where there is test flake in when running vitest tests with non-isolate mode. This is related to a bug in Vitest.

The fix switches the order of the following statement from:

const _isRunningFromThisFile = import.meta.url.includes(globalThis.__vitest_worker__.filepath ?? _expect.getState().testPath);

to

const _isRunningFromThisFile = import.meta.url.includes(_expect.getState().testPath ?? globalThis.__vitest_worker__.filepath );

Once this bug is fixed in vitest-dev/vitest#6367 we can replace the code again. There is a reminder as a code comment.

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 pull request has been released as version 0.0.0-pr-28993-sha-5e4d9ae9. Try it out in a new sandbox by running npx storybook@0.0.0-pr-28993-sha-5e4d9ae9 sandbox or in an existing project with npx storybook@0.0.0-pr-28993-sha-5e4d9ae9 upgrade.

More information
Published version 0.0.0-pr-28993-sha-5e4d9ae9
Triggered by @yannbf
Repository storybookjs/storybook
Branch yann/fix-isolate-false-issue
Commit 5e4d9ae9
Datetime Wed Aug 28 11:36:49 UTC 2024 (1724845009)
Workflow run 10595892999

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=28993

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 76.4 MB 76.4 MB 0 B 0.25 0%
initSize 161 MB 161 MB 961 B -0.67 0%
diffSize 84.8 MB 84.8 MB 961 B -0.67 0%
buildSize 7.48 MB 7.48 MB 0 B 1.73 0%
buildSbAddonsSize 1.62 MB 1.62 MB 0 B 0.49 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 2.31 MB 2.31 MB 0 B 1.73 0%
buildSbPreviewSize 352 kB 352 kB 0 B 0.5 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.47 MB 4.47 MB 0 B 1.73 0%
buildPreviewSize 3.01 MB 3.01 MB 0 B 1.73 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 15.9s 23.7s 7.8s 1.08 33%
generateTime 21.7s 21.2s -558ms -0.17 -2.6%
initTime 17.5s 18.6s 1s 1.01 5.8%
buildTime 11.4s 10.3s -1s -88ms -2.09 🔰-10.5%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 9.7s 6.6s -3s -90ms -1 -46.5%
devManagerResponsive 6s 4.4s -1s -684ms -0.88 -38.2%
devManagerHeaderVisible 941ms 740ms -201ms -0.81 -27.2%
devManagerIndexVisible 991ms 775ms -216ms -0.83 -27.9%
devStoryVisibleUncached 1.7s 1.3s -345ms -0.25 -25.1%
devStoryVisible 990ms 776ms -214ms -0.82 -27.6%
devAutodocsVisible 1s 688ms -393ms -0.63 -57.1%
devMDXVisible 998ms 667ms -331ms -0.7 -49.6%
buildManagerHeaderVisible 1s 696ms -346ms -0.82 -49.7%
buildManagerIndexVisible 1s 729ms -315ms -0.57 -43.2%
buildStoryVisible 1s 731ms -365ms -1.06 -49.9%
buildAutodocsVisible 760ms 705ms -55ms -0.02 -7.8%
buildMDXVisible 858ms 619ms -239ms -0.92 -38.6%

Greptile Summary

This PR addresses a test flakiness issue in non-isolate mode for Vitest tests by modifying the order of properties in a nullish coalescing expression.

  • Changed order in _isRunningFromThisFile declaration to prioritize globalThis.__vitest_worker__.filepath
  • Added TODO comment to remind developers to revert changes once Vitest bug is fixed
  • Updated transformer.test.ts to reflect the changes in the implementation
  • Temporary fix for issue Error with Storyshots, Jest and Canvas #6367 in Vitest repository

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

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

Copy link

nx-cloud bot commented Aug 28, 2024

☁️ Nx Cloud Report

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

@yannbf yannbf merged commit c0f25c1 into next Aug 28, 2024
56 checks passed
@yannbf yannbf deleted the yann/fix-isolate-false-issue branch August 28, 2024 20:32
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