From e70c829aeb7d983eeca184c4d64c01dcf3fb8711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Maisse?= Date: Fri, 26 Feb 2021 08:32:28 +0100 Subject: [PATCH] fix: add `disable` flag to chromatic only when it is computed to `true` Otherwise, it can override some default value --- stories/lib/make-story.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/stories/lib/make-story.js b/stories/lib/make-story.js index ce47e9bd..a0d1717f 100644 --- a/stories/lib/make-story.js +++ b/stories/lib/make-story.js @@ -126,13 +126,6 @@ export function makeStory(...configs) { const mdxSource = dom != null ? domSource() : generatedSource(); - // Disable Chromatic for stories with `skeleton` or `loading` properties or - // with async process using `simulations` fields. Otherwise there are some - // false positive changes related to animation etc - const hasItemWithLoadingAttribute = items.some((item) => item.loading); - const hasItemWithSkeletonAttribute = items.some((item) => item.skeleton); - const automaticallyDisableChromatic = simulations.length > 0 || hasItemWithLoadingAttribute || hasItemWithSkeletonAttribute; - storyFn.docs = docs; storyFn.css = css; storyFn.component = component; @@ -148,9 +141,19 @@ export function makeStory(...configs) { storySource: { source: mdxSource, }, - chromatic: { disable: automaticallyDisableChromatic }, }; + // Disable Chromatic for stories with `skeleton` or `loading` properties or + // with async process using `simulations` fields. Otherwise there are some + // false positive changes related to animation etc + const hasItemWithLoadingAttribute = items.some((item) => item.loading); + const hasItemWithSkeletonAttribute = items.some((item) => item.skeleton); + const automaticallyDisableChromatic = simulations.length > 0 || hasItemWithLoadingAttribute || hasItemWithSkeletonAttribute; + + if (automaticallyDisableChromatic === true) { + storyFn.parameters.chromatic = { disable: automaticallyDisableChromatic }; + } + if (name != null) { storyFn.name = name; }