Tests are great because:
- They allow you to refactor your code
- They are great documentation (i.e. they never get out of sync with the code)
Therefore we should make it as easy as possible to write tests.
Tests are easy to write if:
- Boilerplate is minimal
- They are close to the code being tested. When your tests are in another file you need go to that file to read the tests. This is a small inconvenience. Given that you're reading code all day long it is worth removing that small inconvenience. Also when you're writing tests it's nice to have the code close at hand to see what test cases you're missing.
During our webinar, our guest speaker Yaan Buydens, The technical co-founder of Awell Health will talk about
the testing library that executes the tests in JSDoc.