jest-jsxstyle
Jest utilities for jsxstyle
The problem
If you use jsxstyle
as your CSS-in-JS solution, and you use
snapshot testing with jest then you probably have some test
snapshots that look like:
Hello World
And that's not super helpful from a styling perspective. Especially when there are changes to the class, you can see that it changed, but you have to look through the code to know what caused the class name to change.
This solution
This allows your snapshots to look more like:
.jsxstyle-0 {color:red;display:block;} Hello World
This is much more helpful because now you can see the CSS applied and over time it becomes even more helpful to see how that changes over time.
Installation
This module is distributed via [npm][npm] which is bundled with [node][node] and
should be installed as one of your project's devDependencies
:
npm install --save-dev jest-jsxstyle
Usage
At the top of your test file:
expect
Or in your Jest serializer config:
"snapshotSerializers": "jest-jsxstyle"
And here's how we'd test them with react-test-renderer
:
Works with enzyme too:
Inspiration
LICENSE
MIT