Problem: People forget to write tests
Problem: People forget to write tests.
Solution: Write a test that asserts that each file has a test. π
Below, I'm using Jest to assure each component in our reusable component library has a corresponding test file.
See alt tag for Gist link.

You might think - Isn't that what code coverage is for? The problem with code coverage is it notifies me too late.
If my new code doesn't drop our code below the threshold, I may not realize I forgot to write a test.
With this approach, the build fails immediately.
Many replies think requiring a test for each component is overkill. Perhaps. I don't suggest always using this pattern.
But, whatβs a situation where youβd want to publish a reusable component used by dozens of teams with no tests? For me, the answer is never.
Context matters.