For my third issue for Hacktoberfest, I chose to contribute to the Codelab project. Codelab is a web application built in Angular that offers free and interactive tutorials for learning Angular and TypeScript. This blog post will briefly discuss how I tackled the issue and what I learned in the process.
The Issue Explained
This issue specifies the need to migrate the project tests from Karma to Jest. The Codelab project has many tests that are run using the Karma test runner. But Karma test runner is slow compared to the Jest testing framework. So this issue was opened to help refactor all the tests to use Jest.
To get started, I first read the contribution guidelines and set up my development environment. The development tools required for this project were Node.js, Angular and NX ( Extensible Dev Tools for Monorepos). The project is based on the Angular framework. As the issue deals with code migration, I figured that I would have to narrow down the test files that need to be refactored. So I used the file search feature in GitHub to determine the number of files with the extension ‘.spec.ts’ i.e. the tests are written using Karma. I found that there were 50+ such tests.
Given the amount of work and time required to migrate all the tests, I discussed with the author of the issue whether we can break up the work app-wise (as there are five apps bundled into this one repository). I had to read up on the similarities and differences between the Karma test runner and Jest by skimming through their documentation. Then I started migrating the tests from the main codelab app. I planned to open a pull request once my refactored tests ran successfully without decreasing the current level of code coverage. But unfortunately for me, another contributor opened a pull request to fix this issue even though it was assigned to me. So I ended up doing redundant work for this issue. But I did get some insight into how the Karma test runner and the Jest framework work. So I have listed my learning outcomes below.
- Revised how to develop web applications with Angular.
- Learned to use the NX development tool.
- Learned how to use the Karma test runner.
- Learned how to write tests using the Jest framework.