DEV Community

Discussion on: July 14th, 2022: What did you learn this week?

Collapse
 
mrcaidev profile image
Yuwang Cai • Edited

I dipped into Jest & React Testing Library, and managed to integrate them into my Next.js app. But I still have no idea about the best practices, so would someone be so kind to share some awesome posts on this topic? 💕

Collapse
 
ninofiliu profile image
Nino Filiu

Well there's this amazing article Why Good Developers Write Bad Unit Tests, it's not focused on react + jest, but most of the philosophy can be used anywhere you're writing tests!

It also exists as a talk

Collapse
 
mrcaidev profile image
Yuwang Cai

Thanks! This post is of great help! But I don't think it's always right to "keep the reader in your test function", which the author considered a principle. I think it's necessary to extract common logic into another function, like beforeAll and beforeEach in Jest, for stuffs like database mocking.