Test driven development
Test-driven-development. There’s no other way to do this.
Always write tests first! Always have failing tests before writing the code! Write code in small iterations.
Write the next failing test once the first iteration passes the test. Repeat until finished.
That’s how you do it.
Or not.
You can write your feature, your code. And write a test afterwards. Like a regression test. Sometimes that’s what you do, when you use snapshot testing for React components.
Either way it’s your decision as a professional to make what way you want to develop and test. You get paid to make the right decision, but it is your decision to make. Not somebody else’s. Please don’t forget that. Don’t run around and blindly spread the gospels of our software dev gods. You get paid for thinking and without thinking we could have a machine write the code for us.
Holger