Storybook: Angular Storyshots 5.0.6: Cannot read property 'get' of undefined

Created on 11 Apr 2019  路  22Comments  路  Source: storybookjs/storybook

Describe the bug
I was trying to follow the tutorial from https://www.learnstorybook.com/angular/en/simple-component/ but got a lot of trouble (the doc for jest-preset-angular is not up to date and hard to find the right way).

I'm stuck with last step, I think I configured everything up but when I run the jest test angularshots.test.ts fail. it look like it's the import 'global' which doesn't work properly from addon-storyshots/dist/api/index.js.

To Reproduce
Steps to reproduce the behavior:

  1. Clone repository at https://github.com/chromaui/learnstorybook-code/tree/angular
  2. Apply the patch from attached file (remove .txt in the extension)
  3. Run "npm i"
  4. Run "npm run jest"
  5. See error

I personally use Intellij IDEA built-in Jest runner which is more visual (screenshot come from it)

migrate_to_v5.patch.txt

Expected behavior
The test should run like for the v3 version of the repo

Screenshots
v5
image

v3
image

System:

  • OS: MacOS
  • Device: MacBook Pro (15-inch, 2018)
  • NodeJS: v11.12.0
  • Framework: Angular 7.3.8
  • Addons: storyshots
  • Version: 5.0.6
storyshots angular bug todo

Most helpful comment

I got the same problem with

  • Storyshots ^5.0.11
  • OS: Windows 10
  • Node v11.12.0
  • Angular 8.0.0-rc.4
TypeError: Cannot read property 'get' of undefined

    > 1 | import initStoryshots, { multiSnapshotWithOptions } from '@storybook/addon-storyshots';
        | ^
      2 | 
      3 | initStoryshots({
      4 |     test: multiSnapshotWithOptions({}),

      at _interopRequireWildcard (node_modules/@storybook/addon-storyshots/dist/api/index.js:22:331)
      at Object.<anonymous> (node_modules/@storybook/addon-storyshots/dist/api/index.js:8:15)
      at Object.<anonymous> (node_modules/@storybook/addon-storyshots/dist/index.js:52:35)
      at Object.<anonymous> (src/storyshots.test.ts:1:1)

All 22 comments

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

I got the same problem with

  • Storyshots ^5.0.11
  • OS: Windows 10
  • Node v11.12.0
  • Angular 8.0.0-rc.4
TypeError: Cannot read property 'get' of undefined

    > 1 | import initStoryshots, { multiSnapshotWithOptions } from '@storybook/addon-storyshots';
        | ^
      2 | 
      3 | initStoryshots({
      4 |     test: multiSnapshotWithOptions({}),

      at _interopRequireWildcard (node_modules/@storybook/addon-storyshots/dist/api/index.js:22:331)
      at Object.<anonymous> (node_modules/@storybook/addon-storyshots/dist/api/index.js:8:15)
      at Object.<anonymous> (node_modules/@storybook/addon-storyshots/dist/index.js:52:35)
      at Object.<anonymous> (src/storyshots.test.ts:1:1)

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Up (to not get closed again for nothing...)

Hi, I have the same problem. Did you solve it?

@smikolajewicz , no it's style waiting to be resolved

Hi, I'm also having the same issue. Did anyone find a solution yet?

@AkshayRana92 @rfreydi any luck setting it up? Getting the same exact error and can't figure out why :|

Hi, same issue on my side (Angular 8.2.12 & Storybook 5.2.5).
+1 about the fact that the tutorial would require a refresh to fit with current jest-preset-angular version.

I can reproduce in in master but not in next. Still have to find out what fixed it

UPD: seems fixed in babel with https://github.com/babel/babel/pull/10161. I'll update corresponding dependencies in master

I seem to be getting this in 5.2.6 馃槦

@shilman https://github.com/storybookjs/storybook/pull/8776 is yet unreleased, right?

Hmm, running this on Node 10 (matching our build server) this issue goes away, but on my new laptop (with Node 13.2.0) it fails 馃し鈥嶁檪

Yes, it's an issue specific to newer Node versions

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

This is now resolved as of 5.3.3

awesome! closing!

This is now resolved as of 5.3.3

No i installed a fresh copy from create react app and then storybook with npx -p @storybook/cli sb init --type react_scripts
. But still getting the same error

@arun678 this is an angular issue?

@arun678 this is an angular issue?

No, it's react. But have encountered same error.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MrOrz picture MrOrz  路  3Comments

purplecones picture purplecones  路  3Comments

tirli picture tirli  路  3Comments

alexanbj picture alexanbj  路  3Comments

rpersaud picture rpersaud  路  3Comments