Addon-Vitest: Add channel API to programmatically trigger test runs - #33206
Conversation
|
View your CI Pipeline Execution ↗ for commit a3aad16
☁️ Nx Cloud last updated this comment at |
|
Failed to publish canary version of this pull request, triggered by @JReinhold. See the failed workflow run at: https://github.com/storybookjs/storybook/actions/runs/19732250010 |
…don-vitest-trigger-api
|
Failed to publish canary version of this pull request, triggered by @JReinhold. See the failed workflow run at: https://github.com/storybookjs/storybook/actions/runs/21150762531 |
|
Failed to publish canary version of this pull request, triggered by @JReinhold. See the failed workflow run at: https://github.com/storybookjs/storybook/actions/runs/21150973271 |
|
Failed to publish canary version of this pull request, triggered by @JReinhold. See the failed workflow run at: https://github.com/storybookjs/storybook/actions/runs/21151373423 |
…don-vitest-trigger-api
…don-vitest-trigger-api
…don-vitest-trigger-api
Works on storybookjs/mcp#138
Companion PR: storybookjs/mcp#131
What I did
Added a new programmatic trigger to
addon-vitest, which allows external actors (like addon-mcp) to trigger a test run and get results back via events on the channel.To support this, I had to make additional modifications:
options, so that any preset property (likeexperimental_devServer) automatically has access to the channel and can do stuff with it.Previously, it would fetch the
index.jsonwhen necessary; however, it wouldn't know which origin/url to fetch from. To know that, the manager would send the origin to the server (indexUrl) on startup, because the client does know where to fetch the index from. If this sounds bad, it's because it was, but it was a good compromise at the time.But not anymore, because now you can trigger tests without even opening the manager UI once, which would leave
indexUrlundefined, and crash the test run. So now it does the more clear thing, which is possible as of recently, but wasn't before. Nowaddon-vitestgets the index directly fromStoryIndexGeneratoron the server, and subscribes to changes to the index, so that when tests are triggered, the index is already available and up-to-date.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
addon-mcpinstalled from Add testing toolset mcp#131run-story-teststool and report which stories passed or failed."Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake 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-33206-sha-06900f2a. Try it out in a new sandbox by runningnpx storybook@0.0.0-pr-33206-sha-06900f2a sandboxor in an existing project withnpx storybook@0.0.0-pr-33206-sha-06900f2a upgrade.More information
0.0.0-pr-33206-sha-06900f2ajeppe/addon-vitest-trigger-api06900f2a1770382401)To request a new release of this pull request, mention the
@storybookjs/coreteam.core team members can create a new canary release here or locally with
gh workflow run --repo storybookjs/storybook publish.yml --field pr=33206Summary by CodeRabbit
New Features
Refactor
Tests