diff --git a/addons/storyshots/src/test-bodies.js b/addons/storyshots/src/test-bodies.js index d92865fb27ac..ca83521be6ef 100644 --- a/addons/storyshots/src/test-bodies.js +++ b/addons/storyshots/src/test-bodies.js @@ -10,21 +10,20 @@ function getRenderedTree(story, context, { renderer, serializer, ...rendererOpti return serializer ? serializer(tree) : tree; } -export const snapshotWithOptions = options => ({ story, context }) => { +export const snapshotWithOptions = options => ({ story, context, snapshotFileName }) => { const tree = getRenderedTree(story, context, options); - expect(tree).toMatchSnapshot(); -}; - -export const multiSnapshotWithOptions = options => ({ story, context }) => { - const tree = getRenderedTree(story, context, options); - const snapshotFileName = getSnapshotFileName(context); - if (!snapshotFileName) { + if (snapshotFileName) { + expect(tree).toMatchSpecificSnapshot(snapshotFileName); + } else { expect(tree).toMatchSnapshot(); - return; } - expect(tree).toMatchSpecificSnapshot(snapshotFileName); + tree.unmount(); +}; + +export const multiSnapshotWithOptions = options => ({ context }) => { + snapshotWithOptions({ ...options, snapshotFileName: getSnapshotFileName(context) }); }; export const snapshot = snapshotWithOptions({});