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

Tell us what’s happening:

Run Functional Tests on an API Response using Chai-HTTP IV - PUT method
i passed all test except for the one that says i need to pass all test…

###Your project link(s)

solution: https://7cddb199-a610-4178-af48-fc9726531043-00-2d2fad1th6z5n.kirk.replit.dev

my code:

/ #4
test(‘Send {surname: “da Verrazzano”}’, function (done) {
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();
});
});
});

i also tried with:

// #4
test(‘Send {surname: “da Verrazzano”}’, function (done) {
chai
.request(server)
.keepOpen()
.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();
});
});

});

but it not work…

Tests:

  • Failed:1. All tests should pass

  • Passed:2. You should test for res.status to be 200

  • Passed:3. You should test for res.type to be 'application/json'

  • Passed:4. You should test for res.body.name to be 'Giovanni'

  • Passed:5. You should test for res.body.surname to be 'da Verrazzano'

Your browser information:

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

Challenge Information:

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

Please note that this is an archived course. We cannot help you resolve any bugs you may encounter.

Having said that, you can check the console in the browser to see what errors are being logged.

Hi @SebaTheKnight

Try putting the surname key in quote marks.

Happy coding

hi, it doesn’t work

when i put:

test(‘Send {surname: “da Verrazzano”}’, function (done) {
chai
.request(server)
.keepOpen()
.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();

it says all test fails.

and only works when i put:

test(‘Send {surname: “da Verrazzano”}’, function (done) {
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();

but still says “failed 1 all test should pass” it doesn’t matter test 2,3,4,5 are passed.

it seems the quote marks aren’t the problem, anyway thanks for answer me.