Metric-Imperial Converter tests not passing


I think I have completed the Metric-Imperial converter, I wrote all of the convertHandler, and all of the unit tests and functional tests and all are passing, but when I try to submit the project it always errors out on these test:

I can convert ‘gal’ to ‘L’ and vice versa. (1 gal to 3.78541 L)
I can convert ‘lbs’ to ‘kg’ and vice versa. (1 lbs to 0.453592 kg)
I can convert ‘mi’ to ‘km’ and vice versa. (1 mi to 1.60934 km)

I know that these are working because when I type in those values in the UI and hit Convert, they show up with the correct converted values. Any ideas on why these tests won’t pass? I see a bunch of posts about the QA projects not being fully implemented, so maybe that is why? Should I just wait for a while until those are sorted out? I’d be bummed to make it this far and not be able to complete the courses because they aren’t complete.

Thanks for any help you can provide!


Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.

Challenge: Metric-Imperial Converter

Link to the challenge:

1 Like

Hello there,

I have not debugged fully, but here is some usefull information:

  • The challenge was updated recently. These changes have not reached production yet (there were some delays with recent restructuring)
  • The challenge is currently being worked on, including the boilerplate, and I doubt your current boilerplate will be compatible (I am unsure).
  • I cannot speak for when the changes will be live. So, one thing you can do is make sure your chai/mocha tests are testing properly, then at least you know you have got a handle, and can port your code over, once the changes are live.
1 Like

Thank you for your help. I did make sure my chai/mocha tests are working and all of them are passing. I’ll hold off on these projects for the time being since they are still under construction and come back to them later.

Thanks again!

i have this same problem, i pass all the tests except,

“I can convert 'gal' to 'L' and vice versa. (1 gal to 3.78541 L)”

even tho it works when i type in the value and hit enter

Hi degoke!

I was having the same issue. The issue for me was, the test is actually expecting a lower-case ‘L’ in the returned JSON ‘returnUnit’ key (not helpful when the user story specifically says ‘L’…) Try making sure it returns ‘l’ for liters and see if that fixes it!

Thank you so much, this actually fixed it.
something so minor and to think i almost gave up

Hi there!

I was in the same problem as you: all tests passing but those 3, even when they were working fine… And I finally found the solution. Checking your code, it’s probably the same issue, so check this:
In api.js, returnNum expects a number with 5 decimals. Your convert function in convertHandler.js is returning more decimals, so instead of directly returning the result of the operation in the switch, try to reduce it to just 5.

Hope this helps.

1 Like

Hello Mr Sky. Reporting from the future. Has the update been handled because. I have my unit tests passing but still not working?

Hello there,

Last I checked (within the past 2 months), this project is working as intended.

If you are still stuck, I recommend opening a new topic with all the information you can provide on the subject, and hopefully someone can help debug :slightly_smiling_face: