Skip to content

Commit

Permalink
fix: add disable flag to chromatic only when it is computed to true
Browse files Browse the repository at this point in the history
Otherwise, it can override some default value
  • Loading branch information
gaetanmaisse committed Feb 26, 2021
1 parent e70e048 commit e70c829
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions stories/lib/make-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit e70c829

Please sign in to comment.