Hello everyone! Thanks in advance.
My console shows this and I’ve been seeking up for a while and can’t get why I still have this for some reason:
// running tests
expected 'res.text' to equal 'res.type'
Cannot read property 'method' of undefined
Cannot read property 'method' of undefined
// tests completed
My code so far:
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, 'response status should be 200');
assert.equal(res.type, 'application/json', "Response should be json");
assert.equal(res.body.name, 'Giovanni', 'res.body.name should be "Giovanni"');
assert.equal(res.body.surname, 'da Verrazzano', 'res.body.surname should be "da Verrazzano"');
done();
});
});
// we setup the request for you...
chai.request(server)
.put('/travellers')
/** send {surname: 'Colombo'} here **/
// .send({...})
.end(function(err, res){
/** your tests here **/
assert.equal(res.status,200);
assert.equal(res.type, 'application/json', "Response should be json");
assert.equal(res.body.name , 'Cristoforo');
assert.equal(res.body.surname, 'Colombo'); // remove this after adding tests
done(); // Never forget the 'done()' callback...
});
});
/** Repetition is the mother of learning. **/
// Try it again. This time without help !!
test('send {surname: "da Verrazzano"}', function(done) {
/** place the chai-http request code here... **/
chai.request(server)
.put('/travellers')
.send({surname: 'da Verrazzano'})
/** place your tests inside the callback **/
.end(function(err, res){
assert.equal(res.status,200);
assert.equal(res.type, 'application/json', "Response should be json");
assert.equal(res.body.name , 'Giovanni');
assert.equal(res.body.surname, 'da Verrazzano');
// remove this after adding tests
done();
});
});
});