Skip to content
Discussion options

You must be logged in to vote

Still making Chromatic throw error, chromatic usin setInterval behind the scene to handle some waiting time, here's a possible solution:

Warning

if the component use an interval less than 1 second, it will not use the mocked version

import type { Decorator } from '@storybook/react-webpack5';
import isChromatic from 'chromatic';
import { useEffect } from 'react';

type SetInterval = typeof globalThis.setInterval;
type IntervalParams = Parameters<SetInterval>;

export const ChromaticIntervalDecorator: Decorator = (Story) => {
  useEffect(() => {
    if (isChromatic()) {
      // Save originals
      const originalSetInterval = globalThis.setInterval.bind(globalThis);
      let t: NodeJS.Ti…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@dosubot
Comment options

@Yimiprod
Comment options

@dosubot
Comment options

@Yimiprod
Comment options

Answer selected by Yimiprod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant