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

No decorators in storyshots #1849

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion addons/storyshots/src/test-bodies.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ import shallow from 'react-test-renderer/shallow';
import 'jest-specific-snapshot';
import { getSnapshotFileName } from './utils';

function getElementToRender(element) {
// returns a decorated element if available
try {
return element.props.initialContent.props.children;
} catch (err) {
return element;
}
}

function getRenderedTree(story, context, options) {
const storyElement = story.render(context);
return renderer.create(storyElement, options).toJSON();
const elementToRender = getElementToRender(storyElement);
return renderer.create(elementToRender, options).toJSON();
}

export const snapshotWithOptions = options => ({ story, context }) => {
Expand Down
Loading