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
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
what certificate is it in
Hi Oscar
It is on the Advanced JavaScript and Node, first project.
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
?
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.
I really appreciate your help bro, big time.
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 : so could it be that my browser needs updating maybe?
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.
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
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:
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:
Error: At least 5 tests passed: expected 3 to be at least 5
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. Ngiyabonga(Zulu)
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.