storybook: [Bug]: TypeError: Cannot read properties of undefined (reading 'clientApi')

Describe the bug

After trying to update to storybook@7.0.0-rc.4 for TS 5.0 support, I’m seeing

  ● Test suite failed to run

    TypeError: Cannot read properties of undefined (reading 'clientApi')

      11 | );
      12 |
    > 13 | initStoryshots();
         |               ^
      14 |

      at .yarn/__virtual__/@storybook-addon-storyshots-virtual-f338e9c3bc/0/cache/@storybook-addon-storyshots-npm-7.0.0-rc.4-b1d5a8161c-7f08071aeb.zip/node_modules/@storybook/addon-storyshots/dist/frameworks/react/loader.js:25:49
      at Object.load (.yarn/__virtual__/@storybook-addon-storyshots-virtual-f338e9c3bc/0/cache/@storybook-addon-storyshots-npm-7.0.0-rc.4-b1d5a8161c-7f08071aeb.zip/node_modules/@storybook/addon-storyshots/dist/frameworks/react/loader.js:30:23)
      at loadFramework (.yarn/__virtual__/@storybook-addon-storyshots-virtual-f338e9c3bc/0/cache/@storybook-addon-storyshots-npm-7.0.0-rc.4-b1d5a8161c-7f08071aeb.zip/node_modules/@storybook/addon-storyshots/dist/frameworks/frameworkLoader.js:36:19)
      at testStorySnapshots (.yarn/__virtual__/@storybook-addon-storyshots-virtual-f338e9c3bc/0/cache/@storybook-addon-storyshots-npm-7.0.0-rc.4-b1d5a8161c-7f08071aeb.zip/node_modules/@storybook/addon-storyshots/dist/api/index.js:28:99)
      at Object.<anonymous> ([OBFUSCATED_PATH]/storyshots.test.ts:13:15)

To Reproduce

No response

System

Environment Info:

  System:
    OS: macOS 13.2.1
    CPU: (8) arm64 Apple M1 Pro
  Binaries:
    Node: 18.14.2 - ~/.nvm/versions/node/v18.14.2/bin/node
    Yarn: 3.5.0 - /opt/homebrew/bin/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v18.14.2/bin/npm
  Browsers:
    Chrome: 111.0.5563.64
    Safari: 16.3


### Additional context

_No response_

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 8
  • Comments: 31 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Still not working with 7.0.20.

Why is this closed?

I am also trying @storybook/addon-storyshots but still got the same error Cannot read properties of undefined (reading 'clientApi'). Using @storybook/addon-storyshots version 7.1.1

doesn`t work today

Solved by running: npm install @storybook/preview-api --save-dev

Still not working on 7.3

same problem

I encountered the exact same error message on version 7.3.2.

Using npx storybook@7.4.2 upgrade to upgrade all storybook related dependencies to 7.4.2 resolved the issue.

This helped fix the issue for me, and I was already on Storybook 7.4.1. Looks like upgrading Storybook through npx storybook upgrade even by a patch version can fix some nested dependency to avoid the error.

Oh great, glad it’s not just me then.

@shilman Hi, have the same bug, why is this issue closed? The stable storybook 7.1.x was not released yet

Not working on 7.4

@manuartero @Sangrene 7.1 has been released now which includes a fix for this.

I can say: i got this running when upgraded to 7.1 if anyone needs it i can share my config , but basically bumping to 7.1 did the trick.

thanks

Yes, can you share your config pls?

@manuartero @Sangrene 7.1 has been released now which includes a fix for this.

Shiver me timbers!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.1.0-alpha.10 containing PR #22134 that references this issue. Upgrade today to the @future NPM tag to try it out!

npx sb@next upgrade --tag future