-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
How to use SVG component in Jest? #22
Comments
I discovered a funny solution. I just need to map jest.config.cjs module.exports = {
// Unrelated config
moduleNameMapper: {
// Other config
'^.+\\.svg$': '<rootDir>/src/lib/EmptyIcon.svelte'
},
} EmptyIcon.svelte <svg /> I am not sure if I miss any edge case or something I should know so I don't close it for now. |
Thanks for your feedback. I haven't used it with Jest myself so I can't give you any pointers. Byt this is good info to know and add to the the README file. I will take a look at it when I get time and also update the README with info on testing framework integrations. |
@poppa That's great. By the way, I discovered that |
I am trying to setup Jest unit test but Jest cannot transform
.svg
file. I don't know how to do it when it is imported as a Svelte component.import Exclamation from '$lib/icons/exclamation.svg' <Exclamation />
The text was updated successfully, but these errors were encountered: