canonical-web-and-design / vanilla-framework-react

An implementation of Vanilla Framework using React
19 stars 15 forks source link

Reduce the amount of snapshot tests #135

Open Caleb-Ellis opened 6 years ago

Caleb-Ellis commented 6 years ago

While updating the components to use Vanilla 1.8.0 styling/markup (from 1.6.6) I found that pretty much every component that changed had their tests fail. This was due to the tests being very tightly coupled with the markup (almost 1:1 coupling in fact) meaning that the tests are extremely brittle. I think we should reduce the amount of snapshot tests considerably, in favour of simpler unit tests.

As an example, currently one of the MediaObject tests checks if the large prop works by snapshotting the markup. It would be much simpler to just check if the relevant class (p-media-object--large) is present, rather than the whole markup structure match the snapshot.