All packages should have a "testability" indicator

I mentioned in a tweet that package managers should have an "is testable" field for owners to fill.

I felt the urge to publish that tweet after trying to test my code's functionality by mocking a response coming from a package. This package was making it so difficult for me to mock an API response. That frustrated me a lot.

When a developer uses your package, something you've built, make it easily testable and document the way he can do that.

This way, you increase the developer's trust in you, in your code, and make it easy for him to write his code and test, move on and "forget" that piece of code. You will have lightened his cognitive load, and he will never be afraid of touching that code in the future.

Package registry testability level

Now that I think about it, this makes more and more sense. The owner sets a testability level low|medium|high, that level appears on the package registry page (and GitHub), and people can vote on that That's true|That's false. The package registry can even show a feedback form to get the developer's thoughts. We all know how difficult it is to get feedback.

All of this could be correlated to your CI pipeline and also feed some testing stats like code coverage.


Test your code, and don't let untestable packages stop you from doing that.

No Comments Yet