Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

7
Snapshots for unit tests
Post Body

My co-worker is an experienced frontend web developer. But I have doubts when it comes to his experience in testing.

He uses snapshots for asserting the outputs of helper functions (such as a validation function that returns an object of validated field and their errors).

I personally think it's not a good practice because it's hard to read tests when all you see in the assertion is stuff like expect(myTestFunction(input)).toMatchSnapshot();. But his argument for this is that it gets the job done, and it's fast to write.

I'd argue that it'll be difficult to tell if a test is failing correctly, but I can't really prove my point.

Maybe I'm overthinking it. I've decided to give it a low logaf and not argue with him too much, but I'd like to ask the opinion of the people here, am I right to worry about the incorrect use of snapshots for unit tests?

Author
Account Strength
100%
Account Age
11 years
Verified Email
Yes
Verified Flair
No
Total Karma
17,008
Link Karma
15,605
Comment Karma
1,403
Profile updated: 3 days ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
1 year ago