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

Jest not recognising/updating Storyshots #3483

Closed
Braden1996 opened this issue Apr 24, 2018 · 7 comments
Closed

Jest not recognising/updating Storyshots #3483

Braden1996 opened this issue Apr 24, 2018 · 7 comments

Comments

@Braden1996
Copy link

Braden1996 commented Apr 24, 2018

Bug or support request summary

Hello everyone,

I am trying to setup Storyshots on a project I am working on.
The initial snapshot generation is successful, however, all following changes are not picked up by jest's watch mode. If I want to update the snapshots, I have to use npm run test -- -u - which isn't ideal, as the tests never visibly fail.

From the screenshot in the readme, this shouldn't happen - so I am not sure as to what I am doing wrong.

Steps to reproduce

I am not sure what, in particular, is causing this to happen. My setup uses Microsoft/TypeScript-React-Starter, perhaps that's related. Explicitly writing a snapshot test seems to work as expected, so the issue appears to be solely related to storyshots. I have created a test repository which can be used to reproduce the issue. You can find it here: https://github.com/Braden1996/ts-react-boilerplate

Please specify which version of Storybook and optionally any affected addons that you're running

  • "@storybook/addon-storyshots": "^3.4.1",
  • "@storybook/react": "^3.4.1",

Affected platforms

Please see my project's package.json

Screenshots / Screencast / Code Snippets (Optional)

Screenshot in the readme:
Jest Watch in Readme

Screenshot from my terminal:
screen shot 2018-04-24 at 14 15 22
(notice Snapshots: 0 total)

@Braden1996
Copy link
Author

Okay, so this was a result of using multiSnapshotWithOptions. Unfortunately, as this brilliant article explains, it is a smart "monkey patch" - to state a custom snapshot filename. However, it has a few caveats; including the inability to update snapshots.

@igor-dv
Copy link
Member

igor-dv commented Apr 28, 2018

Hey @Braden1996, multi-snapshots should work with manual updating. I wasn't aware of the watch mode that automatically updates snapshot, so I should probably check it.

@igor-dv
Copy link
Member

igor-dv commented May 7, 2018

Small update here, I've tried multisnapshots outside the storybook (in the jest-specific-snapshot repo) and even though there was no a u command, I was able to press u and to update the snapshots. Here, in storybook it's not available (can't understand why, maybe because of the different Jest versions).

Anyway, I will try to check if it's possible to add a custom command to the watch.

@thomasbertet
Copy link
Contributor

thomasbertet commented May 16, 2018

@igor-dv I did some digging and worked on solving the issue there: igor-dv/jest-specific-snapshot#9. Please let me know what you think of it :)

@igor-dv
Copy link
Member

igor-dv commented Jun 11, 2018

I've published the change as v1.0.0.

@stale
Copy link

stale bot commented Aug 26, 2018

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!

@stale stale bot added the inactive label Aug 26, 2018
@igor-dv
Copy link
Member

igor-dv commented Aug 26, 2018

It was released

@igor-dv igor-dv closed this as completed Aug 26, 2018
@issue-sh issue-sh bot removed the merged label Aug 26, 2018
kotarella1110 added a commit to kotarella1110-sandbox/react-ts-boilerplate that referenced this issue Sep 10, 2018
以下のように、Snapshots ファイルを分割すると、`-u` でアップデートできなくなるため修正。
また、jest-styled-components も上手く機能しない。
storybookjs/storybook#887
以下の issue が参考になりそう。一旦保留とする。
storybookjs/storybook#3483
kotarella1110 added a commit to kotarella1110-sandbox/react-ts-boilerplate that referenced this issue Sep 11, 2018
コンポーネントのストーリごとにファイルを __snapshots__
フォルダを作成するように修正
storybookjs/storybook#3483
storybookjs/storybook#887
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants