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
Create React App allows you to import an svg like so: import iconTrophy from '../images/icon-trophy.svg';
Which actually provides a string, which should be usable in an img tag, but rendering the html from react testing library displays this:
With this line added the html output looks like this: <img alt="Trophy" class="CardIconstyles__IconImg-sc-1oka3lh-1 ipwWdi" src="IconTrophy" />
It would be nice to fix this, and even better to use the filename as CRA does, so adding this: module.exports.default = '${pathname}'; will result in a nicer src: <img alt="Trophy" class="CardIconstyles__IconImg-sc-1oka3lh-1 ipwWdi" src="icon-trophy.svg" />
The text was updated successfully, but these errors were encountered:
@garvae I'd recommend using patch-package to add the lines from my PR linked above.
That's what I do and works perfectly until the owner updates the package or merges my PR
Create React App allows you to import an svg like so:
import iconTrophy from '../images/icon-trophy.svg';
Which actually provides a string, which should be usable in an img tag, but rendering the html from react testing library displays this:
I think this is due to es modules. I have been able to get around this by adding
module.exports.__esModule = true;
to the buildModule function.I found this out from inspecting the CRA src code here:
https://github.com/facebook/create-react-app/blob/main/packages/react-scripts/config/jest/fileTransform.js
With this line added the html output looks like this:
<img alt="Trophy" class="CardIconstyles__IconImg-sc-1oka3lh-1 ipwWdi" src="IconTrophy" />
It would be nice to fix this, and even better to use the filename as CRA does, so adding this:
module.exports.default = '${pathname}';
will result in a nicer src:<img alt="Trophy" class="CardIconstyles__IconImg-sc-1oka3lh-1 ipwWdi" src="icon-trophy.svg" />
The text was updated successfully, but these errors were encountered: