I also notice you have added in the password fields to the forms. Does your app use the password logic before serving the log data? The tests do not give a password.
My code for the 4th test is in database.on("open", function addToLog(req, res) { .... }); and my code for the 5th test is in ``` database.on(“open”, function retrieveLog(req, res) { … });
@Sky020, I ran the test, and then I went into my MongoDB and manually grabbed the 4 _ids inputted by the FCC test run.
1st one: empty array, count: 0
2nd one: count: 1,
3rd one: count: 0,
4th: count: 2
If the test is testing for assert.equal(1, log.length); does that mean that it is expecting the log length of every entry to be 1?
But, that one wont work now because I deleted the database entries so that I could try something else.
But, you can use this (which I left in there to have something to test):
id: 5fb871bf03226800fb206cbc
username: “username1”
password: “password1”
log: Array
__v: 0
@Sky020, I just read another post about the 5th test, and added || date === undefined to my ``` if (date === “”) condition for the date since:
OsakaStarbux said " I was so focussed on passing test 5 that I couldn’t see the real problem. In a perfect world the tests would only test one thing at a time but in this case test 5 bundles the exercise log and unexpected user input (for another route, not the log route). This is what fooled me. I spent ages guessing what the log output should look like when it was fine.
The real problem was the test setting up the user and exercises ready to be tested. After a user is created the test code hits the exercise/add route to create a log but one of those requests failed because the date parameter is undefined. You need to handle that or the log will not be what the test expects (the exercise doesn’t get created).
This is a little unfair since this can only fail because your form is not being used. The test actually builds a bad request because it can. Also, test 4 (for adding exercises) will pass leaving you with a false sense of security. I think the tests need fixing. I’ll have a go at that once I feel confident.
EDIT: I submitted a pull request for this issue: