DEV Community

Discussion on: How should I start?

Collapse
 
dasheck0 profile image
Stefan Neidig

There is a concept called testing pyramide. The foundation are unit tests. This should be your main focus. Find your elemental building blocks (i.e. functions) and testing them properly. Imagine every case that could occur. Let's look at an example (javascript):

const getDaysBetweenTwoDates = (first, second) => { ... }
Enter fullscreen mode Exit fullscreen mode

The following cases come to mind:

  • what if one or both of the parameters is not set (undefined or null)
  • what if one or both of the parameters is not a date
  • what if second is smaller than first
  • what if first is smaller than second
  • what if first and second are equal

Then test everything and keep updating your test cases if you find a bug in production to avoid regression bugs. Work your way up to more complex scenarios, where multiple functions are called and interact with each other. We call this integration tests. This should be your next step. Finally you may do some snapshot testing or UI testing, which I am not a huge fan of to be honest. Would be much cheaper to hire someone to manually test your UI.

The key here is to be consistent and keep adding test to make your codebase more secure and maintainable. Consider measuring your test coverage to have a grasp on how much of your code is tested.

Collapse
 
alanmbarr profile image
Alan Barr

Interesting! How would apply this with accessibility?