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

Mocking Component in Jest #51

Open
TannerJuby1 opened this issue Feb 24, 2022 · 1 comment
Open

Mocking Component in Jest #51

TannerJuby1 opened this issue Feb 24, 2022 · 1 comment

Comments

@TannerJuby1
Copy link

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?

@jacobmischka
Copy link
Owner

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

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

No branches or pull requests

2 participants