Using the knowledge I’ve gained from working on a capstone project at school, I’ve embarked on my first journey to open source of creating a web service that takes in some text containing words and phone numbers and returning just the phone numbers using google’s phone number library as an assignment from Professor Humphrey.
To give some background information regarding this web service project, here are the the technologies the web service is using
Unit Testing and development
While having prior knowledge is a great place to start, I find that my knowledge of Node.JS still needs significant boost and while road blocks are fun, they can also be frustrating.
One issue I’m encountering is with unit tests. My goal is to split tests based on the route of my web service. Currently I have 2 routes: 1) Root endpoint 2) /api/extract/phone/numbers endpoint. The root endpoint simply returns a JSON that provides hypermedia representation for developers attempting to learn how to use my web service by providing them with information regarding possible methods and the data they need to provide in their HTTP request in order to obtain the desired data, phone numbers! I’ve sprinted ahead and begin writing tests for the two routes keeping the tests for each endpoint in separate files. However, upon running the tests, I discover the extract/phone/numbers endpoint is throwing errors regarding port 3000 already in use. This lead me to believe that both scripts were being executed by Jest at the same time, which requires app.js. I’ve searched high and low with no actual solution on Google in sight. My current solution for the time being, is to put the tests all in one file. However, this proves how frustrating it is to test asynchronous code. It would be nice to have a way of getting tests to execute synchronously to avoid race conditions.
Aside from this problem, the next challenge is to figure out the implementation for findNumbers(), which is currently unimplemented with no support expected from Google in the future. While there is no guarantee that I will have this method implemented in time for my assignment submission, I would still be interested in attempting to provide a solution to this problem by gaining inspiration from Google’s Java implementation.
Until then, the research continues.