Quality assurance and Testing - Issue tracker -> testing error messages!

Tell us what’s happening:
My project passes all freeCodeCamp automated tests except the ones that expect error messages.

When I look at the FCC tester code, I see that it checks for response.error to equal the specified error message.

For instance:

assert.equal(data.error, 'required field(s) missing');

when I do a
res.status(400).send({error: 'required field(s) missing'})

I have to do
assert.equal(res.body.error,'required field(s) missing');

How can I write a message directly to res.error so I can pass these tests.

Your code so far
here is my github:

here is my repl.it url:

Your browser information:

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

Challenge: Issue Tracker

Link to the challenge:

1 Like

As of now my app passes 8/11 tests.

The tests I couldn’t figure out are:

If you send a POST request to /api/issues/{projectname} without the required fields, returned will be the error { error: 'required field(s) missing' }

When the PUT request sent to /api/issues/{projectname} does not include update fields, the return value is { error: 'no update field(s) sent', '_id': _id } . On any other error, the return value is { error: 'could not update', '_id': _id } .

You can send a DELETE request to /api/issues/{projectname} with an _id to delete an issue. If no _id is sent, the return value is { error: 'missing _id' } . On success, the return value is { result: 'successfully deleted', '_id': _id } . On failure, the return value is { error: 'could not delete', '_id': _id } .

Ok I have passed the challenge.

The issue was I was sending status codes alongside the responses like 400 etc.

But FCC automated checker doesn’t work with status codes other then 200.

2 Likes