Quality Assurance and Testing with Chai - Run Functional Tests on an API Response using Chai-HTTP III - PUT method

Tell us what’s happening:
here is my problem in the attached picture and my glitch link is here as well

https://meadow-bright-gravity.glitch.me

Your code so far

Your browser information:

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

Challenge: undefined

Link to the challenge:

anyone here that can help with this?

Hello there.

I cannot access your project. Have you renamed it?

@Sky020
Sorry I thought I sent you the right link

https://qamacktil-test-chai.glitch.me

Thank you

All I can see so far is that you have a space where there should not be:

.send({ surname: ' Colombo'})

Hope this helps

I fixed it but still the same. I have been working on it for 3 days now.

On the link, I still see it as having the added space.

This is what I am getting now after fixing the space

Unfortunately, I cannot see anything wrong. So, I suggest you copy-paste this code:

Click to expand
test('send {surname: "Colombo"}',  function(done){
       
       // we setup the request for you...
       chai.request(server)
        .put('/travellers')
        /** send {surname: 'Colombo'} here **/
        .send({surname: "Colombo"})
        .end(function(err, res){
          
          /** your tests here **/
          assert.equal(res.status,200);
          assert.equal(res.type,'application/json');
          assert.equal(res.body.name, 'Cristoforo');
          assert.equal(res.body.surname,'Colombo');
          done(); // Never forget the 'done()' callback...
        });
      });

It is just a last-ditch effort. Hope this helps

1 Like

Kool
I will let you know what happens.
Thanks

Wow it worked !!
Thanks @Sky020

1 Like

This helped me pass just now too. I don’t know if this is helpful but it seems like it passes when the strings are in single quotes but fails if they are double quotes, for type, name, and surname. Unfortunately if you click “Format this file” in glitch, it replaces single quotes with double quotes. But single quotes on the last 3 tests worked for me.

Thank you, for debugging that. I can see it in the tests, now, and we can get that fixed. :tada:

1 Like

Oh, nice! Glad I could be of help!