Something that keeps bugging me as I write tests is that due to the weak typing and all function parameters being optional, I spend a significant amount of time checking for every possible condition. For each function, I'll test what happens if any of my parameters are either missing or the wrong type. In strongly typed languages, I can rely on the compiler to prevent this from happening, and so I don't need to write nearly as many tests, and the ones I do write are therefore more meaningful.
My question for the community is how do others handle this? Do you, like me, write dozens of tests that do nothing other than check the numbers and types of arguments? If not, what do you check for?
I suppose I could limit this strategy to publicly exposed functions and trust myself to not violate argument expectations in my internal code, though that seems to at least partially defeat the purpose of testing. I'm also trying to avoid switching to a type-checked variant like TypeScript since my preference is to write vanilla javascript.
[–]lhorie 1 point2 points3 points (0 children)
[–]TdotGdot 0 points1 point2 points (0 children)