Metric-Imperial Converter Test failing

Tell us what’s happening:
I can’t pass the test “You can use fractions, decimals or both in the parameter (ie. 5, 1/2, 2.5/6), but if nothing is provided it will default to 1.”
Your project link(s)

solution: https://boilerplate-project-metricimpconverter-fcc.ozanbakan.repl.co
https://repl.it/@OzanBakan/boilerplate-project-metricimpconverter-FCC#controllers/convertHandler.js

Your browser information:

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

Challenge: Metric-Imperial Converter

Link to the challenge:

please help :confused: :skull:

Hello there,

Would you mind providing a link to your project code?

I thought i gave it, sorry.

Here: https://repl.it/@OzanBakan/boilerplate-project-metricimpconverter-FCC#controllers/convertHandler.js

No worries. Thank you, for linking to that.

When I run your code (had to fork your project to start the app, for some reason), I see these errors:

The first 2 are self-explanatory, I would hope?

The last two are indicating that the config in routes/fcc-testing.js does not have the correct process.env.NODE_ENV:

  let error;
  app.get('/_api/get-tests', cors(), function(req, res, next){
    console.log(error);
    if(!error && process.env.NODE_ENV === 'test') return next();
    res.json({status: 'unavailable'});
  },

Now, I cannot see what is in your .env file. So, if you have correctly set it, then the last two errors are just specific to when I forked your code, and you can ignore me mentioning them.

Hope this helps

I could not see a connection with console errors and tests not passing.

My NODE_ENV is set correctly I guess. I still don’t understand why tests do not pass. I tried to console log the inputs while testing, can’t seem to find the problem.

The console errors come from the test assertion output. They are the tests output.

Some of them are saying you are returning a string, when you should be returning a number.

Okay I managed to get all tests passing except ’ Your return will consist of the initNum , initUnit , returnNum , returnUnit , and string spelling out units in the format '{initNum} {initUnitString} converts to {returnNum} {returnUnitString}' with the result rounded to 5 decimals.’

Any ideas?

Again, if you open the browser devtools and look at the console, you will see this error, when you submit:

frame-runner.js:98 Error: expected '2 mile(s) converts to 3.21868 kilometre(s)' to equal '2 miles converts to 3.21868 kilometers'

I think that is quite explicit about what the issue is.

Hope this helps

1 Like

oh okay, sorry about that. I was supposed to look at console where I submit it. Thanks

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