Closed tajo closed 7 years ago
Any way we can ignore the class name alltogether? Can't think of a situation where we'd care about that.
Great work @tajo, final piece in place. I agree with @koddsson, we care only about expect(snapshot.styles).toMatchSnapshot();
to tedious to type 2 lines instead of 1.
Any way we can ignore the class name alltogether? Can't think of a situation where we'd care about that.
There is no way to ignore them. We really need them too since you can have multiple fela generated classNames in one component, so you need to know what is what. Like here.
I agree with @koddsson, we care only about expect(snapshot.styles).toMatchSnapshot();
Wait, why don't we care about snapshot of React component itself? Imo it's still the more important one since broken styles are not nice but broken component is disastrous.
to tedious to type 2 lines instead of 1.
Small price for a perfect coverage and it's still simpler than it was. You don't have to import react-test-renderer and wrap everything with renderer.create()
.
Any way we can ignore the class name alltogether? Can't think of a situation where we'd care about that.
There is no way to ignore them. We really need them too since you can have multiple fela generated classNames in one component, so you need to know what is what. Like here.
I figured that'd be the case, no worries :)
Solves https://github.com/cloudflare/cf-ui/issues/242.
I've added snapshots of styles so we can see what property exactly changed, not only that something (classname) changed. That makes snapshots really useful. Here's the example what happened when I replaced
by
in
<Form>
:The first part is the current state. But the second part actually tells you what property has changed in that CSS class. Isn't that cool, guys? ✋ Here's the way how you can write such a test:
Why to save two separate snapshots and not just
? This way it preserves nice indentation. And those two snapshots are always displayed right after each other.
Also, I moved
felaTestContext()
and this newfelaSnapshot()
intocf-style-provider
so we can easily share the same thing in next na cf-ux.The last thing, I've removed
cf-
prefix, so all classnames can be shorter. Saving bytes.