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,
};
I sometimes let
Claude Codeuseplaywright-clito debug issues on Storybook. However, since isRunningInTest considersHeadlessChromea testing environment, the auto snapshots feature kicks in and my agent gets bamboozled bycommands.setupVisSuite is not a functionerrors.I am registering the addon as follows to avoid this issue: