-
Storybook Story Types
unknown, not read by Jest - Using the following syntax seems to remove theunknownerror in the test files, but it's a verbose, non-elegant solution. The types should infer correctly.const BasicComponent: ComponentStoryFn<typeof Component> = Template.bind({});
@storybook/testing-react- Cannot use import statement outside a module - Solved by allowing@babel/preset-envand@babel/preset-reactto transpile. The problem was that.babelrcwas not being used by Jest to transpile, the config file had to be changed tobabel.config.js.- Icons from
@zenius-one/iconsare not read by Jest. Mock needed. Deeply nested icons, for example the<Link external>Link</Link>component might have a problem. (Error: React__namespace.createElement is not a function). - This is resolved by creating a valid Mock - e.g. SVGMock. It then needs to be mapped accurately withmoduleNameMapper. moduleNameMapperseems to map React SVG Icon files correctly, but not replace the modules which now show up asundefined- The error was due to incorrect name of exports. Visit the Jest issues link to view the detailed solution.- Jest Snapshot tests fail when using Dynamic IDs - Fixed by writing a Custom Serializer that provides deterministic IDs that Jest can use for Snapshot testing.