You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A bug occurs when running Jest / Storybook snapshot testing of components using the library 'react-syntax-highlighter' (https://github.com/react-syntax-highlighter/react-syntax-highlighter). I am not sure that the bug is really linked to the library but rather to the way it exports its components.
Bug stacktrace: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
To Reproduce
Import 'react-syntax-highlighter' in a component and use it :
import{PrismLight}from'react-syntax-highlighter';importscalafrom'react-syntax-highlighter/dist/esm/languages/prism/scala';importokaidiafrom'react-syntax-highlighter/dist/esm/styles/prism/okaidia';// Actually use 'scala'PrismLight.registerLanguage('scala',scala);
Run Jest / Storybook snapshot testing
The tests will fail with the stack strace described above.
Hint
The bug really seems to be linked to the imports. The 'react-syntax-highlighter/dist/esm/languages/prism/scala' import leads to this piece of code :
I don't know if this syntax is somewhat unexpected for Storybook. Also worth noting, Storybook does not fail and displays the components correctly. It is the snapshot testing with Jest that fails.
Describe the bug
A bug occurs when running Jest / Storybook snapshot testing of components using the library 'react-syntax-highlighter' (https://github.com/react-syntax-highlighter/react-syntax-highlighter). I am not sure that the bug is really linked to the library but rather to the way it exports its components.
Bug stacktrace:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
To Reproduce
Hint
The bug really seems to be linked to the imports. The 'react-syntax-highlighter/dist/esm/languages/prism/scala' import leads to this piece of code :
I don't know if this syntax is somewhat unexpected for Storybook. Also worth noting, Storybook does not fail and displays the components correctly. It is the snapshot testing with Jest that fails.
Additional context
Storybook dependencies :
React version :
Jest version :
Typescript version :
The text was updated successfully, but these errors were encountered: