Skip to content

[Bug]: CSFNext .test not working with combined exports. #33275

@eidryn

Description

@eidryn

Describe the bug

When using CSFNext with experimentalTestSyntax=true 'combined' export statements fail to run and break storybook as they do not resolve the AST tree to the underlying variable and the _stories property does not contain the exported story (and therefore __stats cannot be accessed).

export const Primary = meta.story({}) // <= Works fine

const Primary = meta.story({})

export { Primary }; // <= TypeError: Cannot read properties of undefined (reading '__stats')

We use combined exports so that it is easy to check what is exported from a file, especially large ones but this is not compatible with the new .test functionality - though everything else works fine.

Reproduction link

https://stackblitz.com/edit/github-gyecjlwc?file=README.md

Reproduction steps

  1. Go to above link
  2. Access the Button story and observe working correctly with in-line export, and separate export at EOF
  3. Uncomment the Secondary.test() function.
  4. Observe storybook breaks

System

│  Storybook Environment Info:
│

│  System:
│  OS: macOS 26.2
│  CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
│  Shell: 5.9 - /bin/zsh
│  Binaries:
│  Node: 24.11.0 - ~/.nvm/versions/node/v24.11.0/bin/node
│  Yarn: 1.22.19 - ~/.yarn/bin/yarn
│  npm: 11.6.1 - ~/.nvm/versions/node/v24.11.0/bin/npm <----- active
│  pnpm: 10.20.0 - ~/Library/pnpm/pnpm
│  Browsers:
│  Chrome: 142.0.7444.60
│  Safari: 26.2
│  npmPackages:
│  @storybook/addon-a11y: 10.1.4 => 10.1.4
│  @storybook/addon-docs: 10.1.4 => 10.1.4
│  @storybook/addon-themes: 10.1.4 => 10.1.4
│  @storybook/addon-vitest: 10.1.4 => 10.1.4
│  @storybook/react-vite: 10.1.4 => 10.1.4
│  eslint-plugin-storybook: 10.1.4 => 10.1.4
│  storybook: 10.1.4 => 10.1.4
│  storybook-addon-tag-badges: 3.0.2 => 3.0.2

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions