Tell us what’s happening:
I cant seem to pass this challenge. I can pass the other 2 fine. i’ve tried changing single quotes to double with no luck. at default, it doesnt pass any test. if i change test to 4, it passes 1 test. if i change test to 5 it passess most except span name and span surname. looking at the assertion. it shows the correct info on test 5. what am i doing wrong here?
Your code so far
var chai = require('chai');
var assert = chai.assert;
var server = require('../server');
var chaiHttp = require('chai-http');
chai.use(chaiHttp);
suite('Functional Tests', function() {
test('Asynchronous test #example', function(done){
setTimeout(function(){
assert.isOk('Async test !!');
done();
}, 500);
});
suite('Integration tests with chai-http', function() {
suite('GET /hello?name=[name] => "hello [name]"', function(){
test('#example - ?name=John', function(done){
chai.request(server)
.get('/hello?name=John')
.end(function(err, res){
assert.equal(res.status, 200, 'response status should be 200');
assert.equal(res.text, 'hello John', 'response should be "hello John"');
done();
});
});
// #1
test('Test GET /hello with no name', function(done){
chai.request(server)
.get('/hello')
.end(function(err, res){
assert.equal(res.status, 200);
assert.equal(res.text, 'hello Guest');
done();
});
});
// #2
test('Test GET /hello with your name', function(done){
chai.request(server)
.get('/hello?name=xy_z')
.end(function(err, res){
assert.equal(res.status, 200);
assert.equal(res.text, 'hello xy_z');
done();
});
});
});
suite('PUT /travellers', function(){
// #3
test('#example - responds with appropriate JSON data when sending {surname: "Polo"}', function(done){
chai.request(server)
.put('/travellers')
.send({surname: 'Polo'})
.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, 'Marco', 'res.body.name should be "Marco"');
assert.equal(res.body.surname, 'Polo', 'res.body.surname should be "Polo"' );
done();
});
});
// #4
test('send {surname: "Colombo"}', function(done){
chai.request(server)
.put('/travellers')
.send({surname: 'Colombo'})
.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, 'Cristoforo', 'res.body.name should be "Cristoforo"');
assert.equal(res.body.surname, 'Colombo', 'res.body.surname should be "Colombo"' );
done();
});
});
// #5
test('send {surname: "Vespucci"}', function(done){
chai.request(server)
.put('/travellers')
.send({surname: 'Vespucci'})
.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, 'Amerigo', 'res.body.name should be "Amerigo"');
assert.equal(res.body.surname, 'Vespucci', 'res.body.surname should be "Vespucci"' );
done();
});
});
// #6
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();
});
});
});
});
var Browser = require('zombie');
Browser.site = 'https://boilerplate-mochachai.drbworld.repl.co';
suite('e2e Testing with Zombie.js', function() {
const browser = new Browser();
suiteSetup(function(done) {
return browser.visit('/', done);
});
suite('"Famous Italian Explorers" form', function() {
test('#example - submit the input "surname" : "Polo"', function(done) {
browser
.fill('surname', 'Polo')
.pressButton('submit', function(){
browser.assert.success();
browser.assert.text('span#name', 'Marco');
browser.assert.text('span#surname', 'Polo');
browser.assert.element('span#dates', 1);
done();
});
});
test('submit "surname" : "Colombo" - write your e2e test...', function(done) {
browser
.fill('surname', 'Colombo')
.pressButton('submit', function(){
browser.assert.success();
browser.assert.text('span#name', 'Cristoforo');
browser.assert.text('span#surname', 'Colombo');
browser.assert.element('span#dates', 1);
done();
});
});
test('submit "surname" : "Vespucci" - write your e2e test...', function(done) {
browser
.fill('surname', 'Vespucci')
.pressButton('submit', function(){
browser.assert.success();
browser.assert.text('span#name', 'Amerigo');
browser.assert.text('span#surname', 'Vespucci');
browser.assert.element('span#dates', 1);
done();
});
});
// test('submit "surname" : "da Verrazzano" - write your e2e test...', function(done) {
// browser
// .fill('surname', 'da Verrazzano')
// .pressButton('submit', function(){
// browser.assert.success();
// browser.assert.text('span#name', 'Giovanni');
// browser.assert.text('span#surname', 'da Verrazzano');
// browser.assert.element('span#dates', 1);
// done();
// });
// });
});
});
});
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36
.
Challenge: Run Functional Tests using a Headless Browser
Link to the challenge: