return-youtube-dislike
return-youtube-dislike copied to clipboard
Feature/add unit testing framework and start writing unit tests (acceptance tests)
Hey everyone,
I had a look at the codebase again and there are some opportunities to refactor thinks that were build back in the days, but before we do that we should have tests in place to make sure we don't introduce bugs while refactoring.
That's why I added jest for automated unit and integration testing to the project. I didn't write tests for everything yet, but started with the utils.js
since they were easy to take apart.
Two things I made sure to do:
- I tried to not touch the code that I was testing (other than 1 exception that was necessary -> see changes)
- I am basically writing acceptance tests only for now (Which means I am strictly documenting the current behaviour of the code (There is one example where I am testing behaviour that I would say is buggy currently -> see changes)
The reason behind that is, that it is easier to strictly cover the codebase with tests first and have them as a contract for existing code and later go ahead and change the codebase with the tests as security net.
I used jest as the testing framework because it's in my opinion the most widely used and we can expand it to integration tests as well later on as well (which we should do to minimize manual testing needed when releasing changes in the future)
Let me know what you think of the changes, I'll try and keep my changes conflict free until it get's merged (or declined)
That's the current code coverage report:

Amazing work, this was in my plans for a looong time.
@Anarios (or anyone else who knows): I was gone for some time before opening this PR so I am not sure what the current approval/review workflow is. I see there are 6 reviews required. Do I have to actively request those, or what's the best process?