Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Reflect CSS Modules classnames in snapshots #4

Merged
merged 1 commit into from
Aug 1, 2017
Merged

Reflect CSS Modules classnames in snapshots #4

merged 1 commit into from
Aug 1, 2017

Conversation

papermana
Copy link

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,
<Foo className={styles.bar} />
becomes
<Foo className="bar" />
in a snapshot!
@paweljedrzejczyk paweljedrzejczyk merged commit 7bd2c81 into netguru:master Aug 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants