transform svgs for for jest+react to declutter snapshots
cwmoo740 / jest-svg-transformer Goto Github PK
View Code? Open in Web Editor NEWtransform svgs for for jest+react to declutter snapshots
License: MIT License
transform svgs for for jest+react to declutter snapshots
License: MIT License
When upgrading to Jest 27 and using this transform, this is the output:
Jest: a transform must export something
I’m guessing it’s just something tiny about how Jest transform now expects things, like in this breaking change:
[jest-transform] [BREAKING] Do not export ScriptTransformer class, instead export the async function createScriptTransformer (#11163) (source)
Hi @cwmoo740,
We are using your transformer within our React native application, right now we are adding support for react native web, thus we are using CRA and they are forcing us to switch from:
import Logo from './logo.svg';
-> import {ReactComponent as Logo} from './logo.svg';
I have also mentioned these changes in this issue
What we need to do is change process.js
module.exports
to support both exports, default and named:
module.exports = { default: ${name}, ReactComponent: ${name} };
I believe this would not be a breaking change, It would be super cool if I could provide a pull request or if you could implement it.
Here is a quick fix for postinstall
npm/yarn script:
"postinstall": "sed -e \"s|module.exports = \\${name};|module.exports = {default: \\${name}, ReactComponent: \\${name}};|g\" -i.bak ./node_modules/jest-svg-transformer/lib/process.js",
Hi! Would you be willing to add the source code of your NPM module to this repo?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.