Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of undefined (reading 'map') #277

Closed
omerfaran opened this issue Sep 14, 2022 · 3 comments · Fixed by #278
Closed

TypeError: Cannot read properties of undefined (reading 'map') #277

omerfaran opened this issue Sep 14, 2022 · 3 comments · Fixed by #278
Assignees
Labels
bug Something isn't working

Comments

@omerfaran
Copy link

Describe the bug
I'm trying to run storybook test runner after installing it (being in nx environment):

npx test-storybook --url http://localhost:4400

And getting the error in the terminal:
[test-storybook] TypeError: Cannot read properties of undefined (reading 'map')

I haven't created a reproduction yet because I'm not sure I'm allowed to. Does anyone know if this is actually a bug, or something I'm missing in the installation?

I'm followed this guide: https://storybook.js.org/addons/@storybook/test-runner
And I'm using pnpm to install packages

Thanks a lot in advance!

System:
OS: Windows 10 10.0.22000 (actually it's Windows 11)
CPU: (24) x64 12th Gen Intel(R) Core(TM) i9-12900K
Binaries:
Node: 16.17.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.15.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22000.120.0), Chromium (105.0.1343.33)

@omerfaran omerfaran added the bug Something isn't working label Sep 14, 2022
@Maybach91
Copy link

Maybach91 commented Dec 6, 2022

I have the same issue.

Having this using the 7.0.0-alpha.59 version and want to run just storybook build

info => Loading presets
info => Building manager..
info => Manager built (56 ms)
info => Copying static files: /projectfolder/public at /projectfolder/storybook-static/
ERR! TypeError: Cannot read properties of undefined (reading 'map')
ERR!     at jr (/projectfolder/node_modules/@storybook/core-common/dist/index.js:18:1142)
ERR!     at buildStaticStandalone (/projectfolder/node_modules/@storybook/core-server/dist/cjs/build-static.js:120:62)
ERR!     at async withTelemetry (/projectfolder/node_modules/@storybook/core-server/dist/cjs/withTelemetry.js:63:5)
ERR!     at async qn (/projectfolder/node_modules/@storybook/cli/dist/generate.js:300:460)
ERR!  TypeError: Cannot read properties of undefined (reading 'map')
ERR!     at jr (/projectfolder/node_modules/@storybook/core-common/dist/index.js:18:1142)
ERR!     at buildStaticStandalone (/projectfolder/node_modules/@storybook/core-server/dist/cjs/build-static.js:120:62)
ERR!     at async withTelemetry (/projectfolder/node_modules/@storybook/core-server/dist/cjs/withTelemetry.js:63:5)
ERR!     at async qn (/projectfolder/node_modules/@storybook/cli/dist/generate.js:300:460)

EDIT:
It looks like my stories are the issue. Since I upgraded SB from 5 to 6/7 and did not update the stories itself (just removed deprecated packages). If i pass stories: [] in the main.js then Storybook is rendering, with empty stories. So SB is working fine, i guess. So maybe the stories itself are the issues. @omerfaran perhaps give it a try?

@MatviiStelmakh
Copy link

I faced the same for the project using NX, the main config file knows nothing about stories to go through, because of stories: [].
As a workaround, you can make a separate config file for tests (./storybook/test/main.ts) with

stories: [
    ...rootMain.stories, 
    '../../apps/**/*.stories.ts', 
    '../../libs/**/*.stories.ts',
  ],

and call runner with test-storybook --url http://127.0.0.1:4400 --config-dir .storybook/test.

@shilman
Copy link
Member

shilman commented Feb 17, 2023

We need to catch this error & let people know they need a stories field in their main.js

Perhaps also add to MIGRATION.md if we somehow supported this in 6.x and chose to remove in 7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
5 participants