Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace snapshot tests #1152

Open
penx opened this issue Jan 21, 2019 · 1 comment
Open

Replace snapshot tests #1152

penx opened this issue Jan 21, 2019 · 1 comment
Labels
feature request User requests a new feature

Comments

@penx
Copy link

penx commented Jan 21, 2019

I am pretty sure that the use of Jest snapshots in govuk-frontend is mainly due to their ease of implementation - and could be replaced by tests that use axiom to look for specific properties of the render output.

Using snapshots means that if a change is made that introduces a white space change or changes the html attribute order, according to the snapshot test this is a failure - generally I would say this is a false positive.

This is of particular concern when developing a port and wanting to ensure the port adheres to all of the same unit tests for templates - the snapshots files are hard to manage across projects and raise false positives.

Related:

Some articles against snapshot testing:

From the first link

We've found that in practice, snapshot tests end up making assertions that aren't clearly represented in the test output. The assertion tries to focus on a very specific behavior or attribute, but because the test renders the entire component, it regularly leads to tests that fail for unrelated reasons. It's not immediately clear whether something is actually wrong, especially for developers who are unfamiliar with the component.

@NickColley
Copy link
Contributor

We're generally using snapshots tests to sanity check any composed components that we pass params to, so we're not duplicating the testing we've already done in the specific component tests.

Worth a look to see if we can do this in a friendlier way for porting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request User requests a new feature
Projects
None yet
Development

No branches or pull requests

6 participants