Throwaway projects aside, would you say testing is important?
Tests are important but…
It takes too long…
We don’t have time for that…
I don’t know how…
I do it manually…
My code is perfect!
Have you ever needed to fix something for someone so that it could break someone else?
How to be afraid to touch files created by someone else?
How about it “just stopped working” and when you finally found out why it was because some dependency changed something (or someone changed the file you depend on)?
Are you debugging or testing manually, again the code you’ve been debugging and testing manually since last week?
And what happened…
To waste a lot of time chasing down a bug that appears out of nowhere or to dredge through someone else’s work.
test coding is like
Remember learning to code?
Your first tests will be terrible, but they will help you nonetheless.
Here’s an example:
If you don’t have a test, nothing is already better than nothing.
So start with a test.
Watch and choose which one you prefer:
And then start testing a component, a process, a “happy path”.
how to use it
pnpm here, then you should have
pnpm established globally.
pnpm install # unit tests pnpm test # e2e tests pnpm test:cy
I intentionally made it as naive as possible. The biggest problem is that it is “flaky”, but there are others.
Being flaky means that changes will easily break the test, which means if you test them like this you have to fix the tests every time you change the code.
But… it would work, it would help and even save more time than if you were doing it all manually or just hoping it wouldn’t break.
And as you learn how to test and best practices, you’ll start to refactor your tests (yes, tests are also code that needs to be refactored) and make more flexible testing with fewer bugs (yes, Tests can have bugs too), test also if it’s working, it’s more of a test (eg: you can test accessibility using selectors that work with semantic tags and roles).
The more you test…
In my experience, the more I test and have better coverage, the less I have to rely on manually using it on every change and the less I have to debug.
Not only that, everyone on the team benefits from those tests. They are already there and telling you what should work and how. And when something breaks, it tells everyone exactly where.
If you get a test piece of software, you don’t need to know and keep in your mind all the complicated rules needed to make the code work, so when you need to refactor or change it, you always have to To know if it is still working or not test is not able to catch if break is intended.
So… what other benefits do you get with testing or what still holds you back from testing?
Unsplash. Photo by National Cancer Institute at