Stop Skipping Tests — They’ll Save You Hours

Pratyay DhondPratyay Dhond
4 min read
  • I recently developed kindle-clippings: A tool that makes accessing kindle highlights a breeze!

  • I have been working on the same tool for the past 6 weeks, since June 1 2025.

  • I always wanted to build projects that followed TDD (Test Driven Development).

    • The benefits of TDD clearly outweigh any cons, but it has some added work.

    • The feeling of shipping a product, a tool that works feels so much more productive than thinking and writing test cases, which the users would never even be coming across.

  • That’s why I didn’t start with test cases.

    • Result, I had to spend countless hours debugging for something that worked earlier but suddenly broke in the new version.

This article brings you my personal insights on ‘What tests are and when to use them’.

What are Tests?

  • Tests are the same as regular code. The Difference is they often require a different library.

    • It requires new library for various functionalities it provides such as mocking other functions, declaring tests and checking for expected results.
  • Tests on high level are blocks of code, that check the functionality of your methods against pre-defined cases.

  • Following are the example of test cases which check the functionality of logging the user in with valid and invalid passwords[^1].

  •      describe('Login User', () => {
          it('should login user', async () => {
            const res = await request(app).post('/auth/login').send({
              email: 'test@test.com',
              password: 'password123'
            });
            expect(res.status).toBe(200);
            token = res.body.token;
          });
    
          it('should not login user with incorrect password', async () => {
            const res = await request(app).post('/auth/login').send({
              email: 'test@test.com',
              password: 'incorrect'
            });
            expect(res.status).toBe(401);
          });
        });
    
  • The tests are not limited to this but a good starting point.

Why didn’t I write tests earlier?

  • I was lazy.

  • I knew the tests would save time but had this great idea to build Kindle-Clippings and wanted to deploy fast!

  • What ended up happening? I used to spend hours testing all the edge cases I could think of everytime I had a new release, just to make sure things weren’t breaking.

    • Imagine doing,

      • Google Sign-in, email sign-in with multiple accounts to ensure it works.

      • Processing 3 correct highlight files and 1 incorrect one to check for consistency

      • Deleting and re-creating the database

      • Spamming myself newsletters every minute

  • All this work is now done by `npm run test`.

    • A single command that saves hours of testing time.

What is the advantage of writing tests now?

  • One advantage must be pretty clear by now, Writing tests saves time. But there are more benefits of testing.

  • Writing tests for features is amazing. But you should also write tests for any bugs that occur.

    • This ensures that you have actually solved the bug by writing your code.

    • You won’t regress, having test-cases for bugs encountered in the past ensures that you won’t reintroduce code that causes the same bug again.

  • Writing tests gives you confidence.

    • When you see that your code has passed the x test cases. It feels easier to hit enter on the git push and deploy.
  • Writing tests makes code maintainable.

    • There would be slightly more time taken to write tests, but I have found during my internship that reading tests written for the code you are working on is a great way to know what the expected input and outputs for the application are.

    • Reading tests gives you a rough idea and a starting point to understand the code.

Is writing tests worth the time?

  • If the above section didn’t make it clear, let me say it again, ‘Writing tests is absolutely worth every second it takes you!

  • Writing tests is a skill that you have to build over time, you won’t start writing tests and on the first day be able to use mocks and states for test.

    • But the important part is starting, making that your add function returns the correct result for 2+2 and null+null.
  • Even I use AI at times for taking help for my tests, getting suggestions.

    • But make sure that if you do use AI, you read what it tells you, why it recommends what it recommends, is it really needed for your test-suite and go-on the internet to read about the new concepts.

    • The bad thing with AI is it makes life too comfortable, we end up getting lazy.

    • The good thing, AI gives you relevant information.

      • You should refer to the topic used by AI and you would have the key concepts of testing.

Hey, if you have read this article so far I would really appreciate a like from you, it makes me feel great to know something I wrote has helped you.

Also, leave a comment on what you think resonated with you in the article. Learning-in-public is the way to do learning better.


[^1]: The following tests have been written using the jest library for testing for JavaScript.

20
Subscribe to my newsletter

Read articles from Pratyay Dhond directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Pratyay Dhond
Pratyay Dhond

Learning from my experiences while joking about the stupid mistakes I did in my prior code!