Skip to content

isRunningInTest check causes problems during agentic debugging #829

Description

@hasanayan

I sometimes let Claude Code use playwright-cli to debug issues on Storybook. However, since isRunningInTest considers HeadlessChrome a testing environment, the auto snapshots feature kicks in and my agent gets bamboozled by commands.setupVisSuite is not a function errors.

I am registering the addon as follows to avoid this issue:

const visAddon = addonVis({
  createMissingBaseline: true,
  auto: true,
});

// storybook-addon-vis reads any HeadlessChrome user agent as a test run, so its
// `beforeAll` reaches for vitest commands a plain browser has not got, and the
// preview fails to render. `__vitest_browser__` is the signal it wants;
// setup-vitest.ts asserts it is there when the suite really does run.
const vis: typeof visAddon = {
  ...visAddon,
  beforeAll: (...args) =>
    "__vitest_browser__" in globalThis
      ? visAddon.beforeAll?.(...args)
      : undefined,
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions