Mock (S)CSS file imports in such a way that when they're asked for some property, they return that same property name.
This way,
<Foo className={styles.bar} />
becomes
<Foo className="bar" />
in a snapshot!
This technique/library is based directly on the suggestion in Jest docs. Without it, a lot of the snapshots are useless as they always render either className="undefined" or className="" (I don't know why it's one sometimes and the other other times).
Unfortunately, I currently don't know of a way to test this, other than by modifying my local node_modules. I tried creating a new app using a script from my fork of the repo but I cannot do that because of the way the repo is structured — it lacks a package name and cannot be installed directly with yarn/npm. I believe only the packages/react-scripts part gets published on npm? Please tell me if there is some convenient-ish way for me to test this, otherwise I may have to resort to publishing my fork as its own package...
Mock (S)CSS file imports in such a way that when they're asked for some property, they return that same property name.
This way,
becomes
in a snapshot!
This technique/library is based directly on the suggestion in Jest docs. Without it, a lot of the snapshots are useless as they always render either
className="undefined"
orclassName=""
(I don't know why it's one sometimes and the other other times).Unfortunately, I currently don't know of a way to test this, other than by modifying my local
node_modules
. I tried creating a new app using a script from my fork of the repo but I cannot do that because of the way the repo is structured — it lacks a package name and cannot be installed directly with yarn/npm. I believe only thepackages/react-scripts
part gets published on npm? Please tell me if there is some convenient-ish way for me to test this, otherwise I may have to resort to publishing my fork as its own package...