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

unmount after storyshot snapshot #2417

Merged
merged 2 commits into from
Dec 3, 2017
Merged

unmount after storyshot snapshot #2417

merged 2 commits into from
Dec 3, 2017

Conversation

jrmurad
Copy link
Contributor

@jrmurad jrmurad commented Dec 3, 2017

Issue: Not unmounting after test causes failures when running multiple tests with a shared decorator. Running the test on its own passes.

Possibly a decorator running causes a tested React component to re-render. If that decorator changes the underlying data assumptions of said component, problems arise.

What I did

Fix #2417 which I reported several minor versions ago and included more details on.

  1. unmount after finished with rendered tree
  2. small refactoring so I would only have to call unmount once instead of 3x

How to test

I have an app which this fixes. I could potentially come up with a smaller reproducing app if there are doubts about what this change does.

In my case, the decorator resets my Redux state; each story adds the data its component depends on. (Maybe not an expected use of Storybook but I find it a great way to get a lot of integration testing of reducers+selectors+containers along with presentational components.)

I was getting failures from a random component (always the same one so long as the stories don't change) because its data was wiped away by the decorator's reset and it tried to re-render.

Is this testable with jest or storyshots?

Possibly with jest mock function, counting number of times it is called.

Does this need a new example in the kitchen sink apps?

I don't know.

Does this need an update to the documentation?

I don't think so.

If your answer is yes to any of these, please make sure to include it in your PR.

@codecov
Copy link

codecov bot commented Dec 3, 2017

Codecov Report

Merging #2417 into release/3.3 will decrease coverage by <.01%.
The diff coverage is 83.33%.

Impacted file tree graph

@@               Coverage Diff               @@
##           release/3.3    #2417      +/-   ##
===============================================
- Coverage        18.77%   18.76%   -0.01%     
===============================================
  Files              348      348              
  Lines             8202     8200       -2     
  Branches           891      911      +20     
===============================================
- Hits              1540     1539       -1     
+ Misses            5979     5962      -17     
- Partials           683      699      +16
Impacted Files Coverage Δ
addons/storyshots/src/test-bodies.js 63.15% <83.33%> (+1.25%) ⬆️
app/vue/src/server/config/babel.js 0% <0%> (-100%) ⬇️
lib/ui/src/modules/ui/libs/hierarchy.js 50.74% <0%> (ø) ⬆️
addons/info/src/components/markdown/text.js 33.33% <0%> (ø) ⬆️
app/react/src/demo/Welcome.js 0% <0%> (ø) ⬆️
lib/components/src/navigation/menu_link.js 0% <0%> (ø) ⬆️
addons/jest/src/components/Result.js 0% <0%> (ø) ⬆️
...tories_panel/stories_tree/tree_decorators_utils.js 45.23% <0%> (ø) ⬆️
addons/knobs/src/components/types/Number.js 7.93% <0%> (ø) ⬆️
addons/info/src/components/markdown/code.js 24.13% <0%> (ø) ⬆️
... and 50 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 16cd900...a86df5f. Read the comment docs.

@Hypnosphi
Copy link
Member

Hypnosphi commented Dec 3, 2017

Fix #2417

Looks like it's a typo, #2417 is this PR

tree.unmount();
};

export const multiSnapshotWithOptions = options => ({ context }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactoring

@Hypnosphi Hypnosphi merged commit 295c8b4 into storybookjs:release/3.3 Dec 3, 2017
@jrmurad
Copy link
Contributor Author

jrmurad commented Dec 3, 2017

Sorry for typo. Should have been #1634 which can be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants