DEV Community

Discussion on: The three A’s of Unit Testing

lukeshiru profile image
Luke Shiru

Nice example! I seen some similar posts in which they tested the values of the actual properties instead of the output of methods, which is a very bad practice, because the internal state isn't relevant to unit testing, just the surface of contact with the external world. So:

// Doing it like in your example, which is ideal:

const instance = new Class("value");
const output = instance.method();

// Bad practice I seen:

const instance = new Class("value");
Enter fullscreen mode Exit fullscreen mode

Thanks for sharing! Cheers!

coderjay06 profile image
Jay Cruz

Thanks for sharing this Luke! Definitely good to know, I'm pretty new to writing my own tests so trying to learn about best practices