Run Functional Tests on an API Response using Chai-HTTP IV - PUT method (whats my issue)

Tell us what’s happening:

Your project link(s)

solution: https://boilerplate-mochachai-4.henrychang7.repl.co

  test('send {surname: "da Verrazzano"}', function (done) {
        chai.request(server)
            .put("/travellers")
            .send({
             surname: "da Verrazzano"
              name: "Giovanni"
            })
            .end(function(err, res) {
              assert.equal(res.status, 200);
              assert.equal(res.type, "application/json");
              assert.equal(res.body.name, "Giovanni");
              assert.equal(res.body.surname, "da Verrazzano");
            done();
          });
      });
    });
});;

Your browser information:

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

Challenge: Run Functional Tests on an API Response using Chai-HTTP IV - PUT method

Link to the challenge:

Hello there,

Small typo here. I would expect the Replit console to give a more useful error?

Hi Sky020,

its still not letting me pass.

test(‘send {surname: “da Verrazzano”}’, function (done) {
chai.request(server)
.put("/travellers")
.send({
surname: “da Verrazzano”
name: “Giovanni”
})
.end(function(err, res) {
assert.equal(res.status, 200);
assert.equal(res.type, “application/json”);
assert.equal(res.body.name, “Giovanni”);
assert.equal(res.body.surname, “da Verrazzano”);
done();
});
});
});
});;

You have not fixed the typo…

You are passing an object. Object entries are separated by a comma

Hope this clarifies.

I am sorry Sky020, when i put the comma in, its still wrong.

I am confused why you included the name property. Here are the instructions:

Send the following JSON response as a payload to the /travellers route:

{
  "surname": "da Verrazzano"
}

Hope this clarfies

I am sorry, I have tried everything in the book and nothing is helping.

test(‘send surname: “da Verrazzano”}’, function (done) {
chai.request(server)
.put("/travellers")
.send({
“surname”: “da Verrazzano”
})
.end(function(err, res) {
assert.equal(res.status, 200);
assert.equal(res.type, “application/json”);
assert.equal(res.body.name, “Giovanni”);
assert.equal(res.body.surname, “da Verrazzano”);
done();
});
});
});

});

Can you find this within server.js:

let error;
app.get('/_api/get-tests', cors(), function (req, res, next) {
  if (error)
    return res.json({ status: 'unavailable' });
  next();
},

Replace it with this:

let error;
app.get('/_api/get-tests', cors(), function (req, res, next) {
  if (error) {
    console.log("Error: ", error);
    return res.json({ status: 'unavailable' });
  }
  next();
},

Then, retry, and let us know what error appears in the console.


Also, when you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Hi, i put in the code and this is what appears in the console.

Right…and, now you can solve the issue:

assert.equal(res.type. 'application/json');

At this point in the curriculum, you should be familiar with interpreting such errors. So, I suggest you continue, and try from here.

I hope this has helped

I am still getting nothing right. Is there a helpdesk I can reach out to.

Issue has been resolved

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.