Metric-Imperial Converter - Project Feedback & Tips

Hi campers,

I have just finished the Metric-Imperial Converter. Take a look if you’d like!

Some tips:

  • .env - To make sure that the Unit and Functional Tests run, make sure you put the variables in sample.env into a new “.env” file. This took me forever to understand, why the tests were not working. This issue I found is unique to Repl.it.

  • “L” versus “l” - A big part of this project is just chasing down the capitalization of liters, so be patient when dealing with this. Make sure that your unit tests also reflect this nuanced capitalization change, because otherwise you will either not pass the unit tests or you won’t pass the project tests. Because you are writing the unit tests yourself, you can make it work so that all tests (unit, function, and overall project tests) pass.

  • Another hint - the “Converter” function works a lot like OOP in the Javascript section, with the master function and various “sub” functions that also fall under it (getUnit, getNum, etc.) So I would review that JS section before proceeding.

  • Null, Undefined, “Invalid” - another big aspect of this project is just understanding how and WHEN you defined “invalid” in the converter functions. Even though the returned JSON should indicate “invalid number” or “invalid unit” or both when you press enter, think about WHEN “invalid number” should be assigned for the converter function results BEFORE the json returns. This will make or break the unit tests and functional tests.

1 Like

Thanks very much for that “.env” paragraph, it helped me realize what the issue was for my Heroku-hosted version of this app!

I didn’t have NODE_ENV=test set in my “Config Vars” in the project settings so the tests were not working.

Hope this helps a fellow Heroku user in the future!

1 Like