Having trouble with QA Project - Metric-Imperial Converter

Tell us what’s happening:
I’m really having trouble with this challenge. I get 13 of the 21 tests to pass, the failed tests all mention TypeError. Feel like I’ve missed something. Also when I go to the solution link and press convert on any input, nothing happens. I’m not sure what I missed.

Your project link(s)

githubLink: https://replit.com/@1nfernox/boilerplate-project-metricimpconverter
solution: https://boilerplate-project-metricimpconverter.1nfernox.repl.co/

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0

Challenge: Metric-Imperial Converter

Link to the challenge:

Any help would be appreciated. I don’t really understand why it doesn’t work. One thing I found is that when i add the /api/convert?input=4gal to the end of my url, it comes up with Not Found on the page. When I look at the code, the only place where Not Found is found is in Server.JS under //404 Not Found Middleware. But still not sure why this is happening.

  1. The reason it returns Not Found, is because your route in api.js (api/convert) is missing a slash.

  2. You have the same error in your functional tests.

  3. In your tests you also made some errors accessing array elements. In some cases you used some_array(index), while in other instances you used the correct some_array[index].

  4. If you fix these errors, there are only two failing tests left. The error messages for these should give an indication as to what you have to fix.

Arrgh I knew it was something I missed. Thanks for the help Ben, really appreciated. All tests passing now, but for some reason, freecodecamp is failing 1 test, see screenshot.

If you open the browser console on the FCC challenge page, you will see the following error:

Error: At least 16 tests passed: expected 6 to be at least 16

FCC is checking how many tests inside the ‘Unit Tests’ suite are passing and it can only find 6 tests instead of the expected 16.

suite('Unit Tests', function(){
  // All passing tests inside this code block will get counted by FCC.
}

So just make sure that all your tests are actually inside this code block and everything should work fine.

Note: If you want to see what FCC is actually testing when you submit your link: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/06-quality-assurance/quality-assurance-projects/metric-imperial-converter.md

In your case the following line is causing the error mentioned above:

assert.isAtLeast(unitTests.length, 16, 'At least 16 tests passed');

Thanks Ben, would have never thought to check that. Just moved my closing brackets for that suite to the bottom and it passes now. Thanks again for all your help.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.