Metric Imperial Converter Test fo 10L and kg please help

I can’t get the 10L and 1kg assertions to pass, what Am I doing wrong?? Also I don’t know what is wrong with the solution link sometimes it works other times not…PLEASE HELP

Screenshot_2021-01-26 boilerplate-project-metricimpconverter

1 Like

what certificate is it in

Hi Oscar
It is on the Advanced JavaScript and Node, first project.

1 Like

routes/api.js
Line 36: where do you declare result?
Line 39: where do you declare results?

controllers/convertHandler
Line 17: where do you declare nums?

1 Like

Thanks for that heads up @jenovs, I changed those and it does convert and display as all the tests pass, except it doesn’t insert the invisible 1 kg and says that there is an assertion error expecting 500 I’m dizzy now, does it have to do with my res.status maybe and my regex?

In routes/api.js you’re still trying to return results which doesn’t exist.

2 Likes

I really appreciate your help bro, big time.


My app is working now pretty well, but the functional tests seem to be having an issue, did I miss something maybe cos on my console in repl.it everything is fine but there are 19 tests passing and I think there should be 21: ![Screenshot_2021-01-28 boilerplate-project-metricimpconverter(3)|479x500]
And fcc solution tester is playing games:(upload://3nHQnJibDjTa2WDQs3fuGiHdwIh.png)

Don’t Leave Me Here I Am almost done, I am grateful for your time and assistance up to so far.(Don’t quit being awesome man)

Why is it that when I run the tests on repl.it, the undefined variable does not replace with the number one :

Here is a link to test : https://repl.it/join/ulrrugyd-kennethbit

Here is what the test runner gives me : Time Out Feedback so could it be that my browser needs updating maybe?


Why is this assertion not working properly?

Here is the code : https://repl.it/join/ulrrugyd-kennethbit

This is part of the problem I think:

      if(!initNum && !initUnit){
        res.send('invalid number and unit');
      }else if(!initNum){
        res.send('invalid number');
      }else if(!initUnit){
        res.send('invalid unit');
      }

in your /api/convert route. When I ran the fCC tests, they mostly failed. When I looked at your console, it was printing conversion responses for invalid numbers. Anytime you send a response, you need to use return res.send(...) or whatever so that route execution stops upon sending the response, otherwise, you’ll send multiple responses like this appears to be doing.

The other thing to check is the string you are returning in the conversion object. You are returning kilogram(s) instead of kilograms.

I can’t tell from your post with which functional test you are struggling, but the two easiest places to diagnose the problem is in your /api/convert route by printing initNum and initUnit after you get them from convertHandler and then log your responses before sending at all four response points to ensure you are sending what you should be sending.

1 Like

Hello there,

I have moved your posts related to this project all into the same thread. Please do not spread out your posts/questions when they regard the same project. This makes the forum untidy, and comes across as spam.


As far as I can tell, there is a syntax error in your code, because I cannot get the functional tests to run on your project:

Until you can run, and pass, all of the unit, and functional tests on the Repl, the fCC tests will not be able to pass.

Hope this helps

1 Like

Apologies for the messy posting and thank you for organizing them into one.

I will do so next time.

It is running now, but I get this in my terminal saying all the tests pass yet the output is clearly incorrect and the test runner seems to be picking this ‘invisible’ mistake up:
Screenshot_2021-02-01 freeCodeCamp org(1) only these two are failing.

It seems all of your problems have to do with syntax errors:

test('Convert 3/7.2/4kg (invalid number)', function (done) {
      chai.request(server)
        .get('/api/convert')
        .query({ input: '33/7.2/4kg' })
        .end(function (err, res) {
          assert.equal(res.status, 200);
          assert.equal(res.body.initNum, undefined);
          done();
        });

      test('Convert 3/7.2/4kilogram (invalid number and unit)', function (done) {
        chai.request(server)
          .get('/api/convert')
          .query({ input: '3/7.2/4kilogram' })
          .end(function (err, res) {
            assert.equal(res.status, 200);
            assert.equal(res.body.initNum, undefined);
            assert.equal(res.body.initUnit, undefined);
            done();
          });

So that you can debug something like this yourself, in the future, this is what I did:

  • Started the project, and saw the tests - looks correct
  • Submitted the project, and opened the browser console:
    • Saw this error: Error: At least 5 tests passed: expected 3 to be at least 5
  • Navigated to the functional tests, and formatted the file
  • Noticed the incorrectly closed test

Hope this helps

P.S. it is odd that you have 3 suites within your functional tests, when you only have 1 set of tests (You do not have to change this, but it is not really the point of the suites)

Thank You A Million Times @Sky020 , @oscar4 , @jenovs, and @jeremy.a.gray … I was just panicking and super excited to start with Python. :smiley: Ngiyabonga(Zulu)