@superevilmegaco/jest-evil-svg-transformer
v0.0.4
Published
Transforms SVGs so Jest won't error out.
Readme
Evil Jest SVG Transformer
Make SVGs work with Jest (just make Jest not error out).
Install with either yarn or npm
Yarn
yarn add --dev @superevilmegaco/jest-evil-svg-transformerNPM
npm i --save-dev @superevilmegaco/jest-evil-svg-transformerPut this in your jest.config.json:
{
"transform": {
"^.+\\.js$": "babel-jest",
"^.+\\.svg$": "@superevilmegaco/jest-evil-svg-transformer"
}
}And Jest won't error out on lines like this:
import UIIcons from "./icons.svg";
if (!document.getElementById("evil-icons")) {
const iconContainer = document.createElement("div");
iconContainer.id = "evil-icons";
iconContainer.style.display = "none";
iconContainer.innerHTML = UIIcons;
document.body.appendChild(iconContainer);
}