Struggling to get tests to pass

Unfortunately the tests for the Exercise Tracker Challenge don’t give a lot of specifics as to why they fail, but I’ve found the source code here. My app seems to me to be returning exactly what the test requires, and it it still fails.

In particular, I’m trying to pass the third test:

I can add an exercise to any user by posting form data userId(_id), description, duration, and optionally date to /api/exercise/add. If no date supplied it will use current date. App will return the user object with the exercise fields added.

Without more information, I’m really struggling to progress through the challenge. My app meets the user story requirements adequately, but the tests fail.

My app and source code are available below:

I’d really appreciate some help on this one. Hasn’t been a great day!

I’ve just discovered that the tests actually throw errors in the Glitch console! I’ll use that as a starting point for attempting to fix. At least I have something to go on, now.

I’ve started making headway by reviewing teach test in detail in the source and logging out req.body, .params, and .query for every request, then following the errors in the Glitch console.

Wish me luck.


Just played about with yours, and noticed that you return the user object in an array when adding an exercise:

The test is asking for an object, so maybe just ditch the array and return the object?

Thanks @ganeshh123!

That was one of many problems I still had. I’m making a lot of headway finally by reading through the test scripts in Github line by line and understanding what the expected response should look like, and also rewriting the tests in Postman to test with directly.

This tutorial would benefit from having the expected response shapes properly documented, and a reference made to how to view/get the test outputs (and specs)!

1 Like

OK, I’ve happily waded through and am on the other side:

The most useful thing I did here was to walk through the test script and rebuild it myself in Postman. You can view my tests here.

I also made sure to console.log() out the details of each request to the app so that I could see a bit more about what the FCC tests were trying to do by looking at the Glitch console.

To do this I just made some basic middleware:

// Request logging for debugging FCC tests
app.use((req, res, next) => {
  console.log('Request Params ->', req.params);
  console.log('Request Query ->', req.query);
  console.log('Request Body ->', req.body);

If anyone needs help getting through this, please feel free to respond with questions.

1 Like

Amazing, well done!

Is the Postman stuff taught in the curriculum, or are we just expected to know it?

Logging the request and response each time is actually an amazing idea!

1 Like

Thanks @ganeshh123, I’m pleased it’s finished but this module is really problematic. I’m going to try and write a guide for it to at least help others if they get stuck, even though apparently it’s going to be replaced.

Is the Postman stuff taught in the curriculum, or are we just expected to know it?

It’s not taught at all and I don’t think it’s even expected that you should know it! A much better approach would be for the exercise to actually explain what the response should look like, and for the tests to log out something other than “failed”.

1 Like