From 9f90d969fcb8bf18db0bd896d1337fda2ead2c03 Mon Sep 17 00:00:00 2001 From: Jason Murad Date: Sun, 3 Dec 2017 00:01:44 -0500 Subject: [PATCH 1/2] unmount after storyshot snapshot --- addons/storyshots/src/test-bodies.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/addons/storyshots/src/test-bodies.js b/addons/storyshots/src/test-bodies.js index d92865fb27ac..8b41119cd01d 100644 --- a/addons/storyshots/src/test-bodies.js +++ b/addons/storyshots/src/test-bodies.js @@ -10,21 +10,19 @@ 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; } + tree.unmount(); +}; - expect(tree).toMatchSpecificSnapshot(snapshotFileName); +export const multiSnapshotWithOptions = options => ({ context }) => { + snapshotWithOptions({ ...options, snapshotFileName: getSnapshotFileName(context) }); }; export const snapshot = snapshotWithOptions({}); From a86df5f9b6d7d661ff7576795ec5d90dd1335c99 Mon Sep 17 00:00:00 2001 From: Jason Murad Date: Sun, 3 Dec 2017 00:08:36 -0500 Subject: [PATCH 2/2] add a blank line --- addons/storyshots/src/test-bodies.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/storyshots/src/test-bodies.js b/addons/storyshots/src/test-bodies.js index 8b41119cd01d..ca83521be6ef 100644 --- a/addons/storyshots/src/test-bodies.js +++ b/addons/storyshots/src/test-bodies.js @@ -18,6 +18,7 @@ export const snapshotWithOptions = options => ({ story, context, snapshotFileNam } else { expect(tree).toMatchSnapshot(); } + tree.unmount(); };