Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.prerelease.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 10.4.0-alpha.15

- Vitest: Fix agent detection breaking runs - [#34681](https://github.com/storybookjs/storybook/pull/34681), thanks @JReinhold!

## 10.4.0-alpha.14

- CLI: Fix agentic check - [#34678](https://github.com/storybookjs/storybook/pull/34678), thanks @yannbf!
Expand Down
14 changes: 8 additions & 6 deletions code/addons/vitest/src/vitest-plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export const storybookTest = async (options?: UserOptions): Promise<Plugin[]> =>
plugins.push(mdxStubPlugin);
}

let agent: ReturnType<typeof detectAgent> | undefined;
let withinAgenticSetupSession = false;

const storybookTestPlugin: Plugin = {
Expand All @@ -267,6 +268,11 @@ export const storybookTest = async (options?: UserOptions): Promise<Plugin[]> =>
.replace('<body>', `<body>${bodyHtmlSnippet ?? ''}`);
},
async config(nonMutableInputConfig, { mode }) {
if (isTelemetryModuleEnabled()) {
agent = detectAgent();
withinAgenticSetupSession = !!agent && (await isWithinInitialSession('ai-setup'));
}

if (mode) {
// Needed for `preset.apply('env')` to work correctly
process.env.BUILD_TARGET = mode;
Expand Down Expand Up @@ -367,7 +373,8 @@ export const storybookTest = async (options?: UserOptions): Promise<Plugin[]> =>

provide: {
[STORYBOOK_CORE_GHOST_STORIES_PROVIDE_KEY]: !!process.env.STORYBOOK_COMPONENT_PATHS,
[STORYBOOK_CORE_RENDER_ANALYSIS_PROVIDE_KEY]: !!process.env.STORYBOOK_COMPONENT_PATHS,
[STORYBOOK_CORE_RENDER_ANALYSIS_PROVIDE_KEY]:
!!process.env.STORYBOOK_COMPONENT_PATHS || withinAgenticSetupSession,
},

include: [...includeStories, ...getComponentTestPaths()],
Expand Down Expand Up @@ -458,11 +465,6 @@ export const storybookTest = async (options?: UserOptions): Promise<Plugin[]> =>
if (isTelemetryModuleEnabled()) {
// When an agent is running vitest via CLI, inject a reporter that sends
// detailed test result telemetry (pass/fail, error analysis, empty renders)
const agent = detectAgent();
withinAgenticSetupSession = !!agent && (await isWithinInitialSession('ai-setup'));
if (withinAgenticSetupSession) {
await context.vitest.provide(STORYBOOK_CORE_RENDER_ANALYSIS_PROVIDE_KEY, true);
}
if (agent && withinAgenticSetupSession) {
context.vitest.config.reporters.push(
new AgentTelemetryReporter({
Expand Down
3 changes: 2 additions & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,6 @@
"Dependency Upgrades"
]
]
}
},
"deferredNextVersion": "10.4.0-alpha.15"
}
Loading