Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support Storybook 6.4 #206

Merged
merged 16 commits into from Mar 17, 2022
Merged

feat: support Storybook 6.4 #206

merged 16 commits into from Mar 17, 2022

Conversation

zhzz
Copy link
Member

@zhzz zhzz commented Feb 24, 2022

Add compatibility with Stroybook 6.4, that has some changes in internal API and story parameters merging strategy.

Improve skip parameter format. Previously you were able define different skip options in one place as an array, you also were able to define another array of skips somewhere else and all these options would be merged in one big array. But Storybook treats arrays as primitive type and since 6.4 it merges global and kind parameters internally. So there is no way to get skips from different parameter levels

diff --git a/src/types.ts b/src/types.ts
index aa24f42..0d3d91c 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -393,16 +393,18 @@ export interface CreeveyStoryParams {
   ignoreElements?: string | string[] | null;
   waitForReady?: boolean;
   delay?: number | { for: string[]; ms: number };
-   skip?: SkipOption | SkipOption[];
+   skip?: SkipOption | SkipOption[] | Record<string, SkipOption | SkipOption[]>;
   tests?: {
     // TODO Define browserName, story
     [name: string]: CreeveyTestFunction;
   };
 }

Now, skip options might be defined as an object with unique keys e.g.:

// MyComponents.stories.tsx
export default {
  title: 'MyComponent'
  parameters: {
    creevey: {
      skip: {
        'MyComponent does not support IE11': { in: 'ie11' },
        'flacky': { stories: ['with Error'] },
      },
    },
  },
};

instead of array:

// MyComponents.stories.tsx
export default {
  title: 'MyComponent'
  parameters: {
    creevey: {
      skip: [
        { in: 'ie11', reason: 'MyComponent does not support IE11' },
        { stories: ['with Error'] },
      ],
    },
  },
};

Note that array can still be used as skip object value:

// preview.tsx
export const parameters = {
  creevey: {
    skip: {
      "flacky": [
        { kinds: ['Button', 'Input'] },
        { stories: 'Loading' },
      ],
    },
  },
};

fix #195

@wKich wKich marked this pull request as ready for review March 14, 2022 12:30
tests/utils.test.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Storybook 6.4.0 - TypeError: Cannot read properties of undefined (reading 'removeAllListeners')
2 participants