gatsby-plugin-react-svg
gatsby-plugin-react-svg copied to clipboard
Mocking Component in Jest
How do you mock these SVG components in Jest?
I import it in my files like suggested, but when it tries to retrieve it I get an error that the Module could not be found.
If I try the suggested Code Transform method from Jest allows the tests to pass, but I get an error because the import ends up being <MyIcon.svg /> which is invalid syntax.
Can we get some documentation on how to test components that use this plugin?
No idea, you'll want to look for solutions for doing the same with the underlying library. This may help: https://stackoverflow.com/questions/46583986/how-can-i-ignore-svg-react-loader-path-to-my-svg-when-testing-with-jest-wi