sollution does not work for me , please assist here is my code below …
Also when i move the setup above i the previous excercises test fails
please help for the life of me i cant figure out what im doing wrong
all tests pass i.e i can assert the name , surname and count but the first test “All tests should passs” keeps failing thank you for assistance…
the error i get is …
23 passing (62ms)
2 failing
- Functional Tests with Zombie.js
“Famous Italian Explorers” form
Submit the surname “Colombo” in the HTML form:
AssertionError [ERR_ASSERTION]: No open window with an HTML document
const chai = require('chai');
const assert = chai.assert;
const server = require('../server');
const chaiHttp = require('chai-http');
chai.use(chaiHttp);
suite('Functional Tests', function () {
this.timeout(5000);
suite('Integration tests with chai-http', function () {
// #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();
});
});
// #3
test('Send {surname: "Colombo"}', function (done) {
chai
.request(server)
.put('/travellers')
.send({
surname: "Colombo",
})
.end(function (err, res) {
assert.equal(res.status, 200)
assert.equal(res.type, 'application/json')
assert.equal(res.body.name, 'Cristoforo')
assert.equal(res.body.surname, 'Colombo')
done();
});
});
// #4
test('Send {surname: "da Verrazzano"}', function (done) {
chai
.request(server)
.put('/travellers')
.send({
"surname": "da Verrazzano"
})
.end((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();
})
});
});
});
const Browser = require('zombie');
Browser.site = 'http://localhost:3000/'; // Your URL here
const browser = new Browser();
// suiteSetup(function(done) {
// return browser.visit('/', done);
// });
suite('Functional Tests with Zombie.js', function () {
this.timeout(5000);
// suiteSetup(function(done) {
// return browser.visit('/', done);
// });
suite('Headless browser', function () {
test('should have a working "site" property', function() {
suiteSetup(function(done) {
return browser.visit('/', done);
});
console.log('wow')
assert.isNotNull(browser.site);
});
});
suite('"Famous Italian Explorers" form', function () {
// #5 'Submit the surname "Colombo" in the HTML form'
test('Submit the surname "Colombo" in the HTML form', function (done) {
browser.fill('surname', "Colombo").then(() => {
browser.pressButton('submit', () => {
browser.assert.success();
browser.assert.text('span#name', 'Cristoforo');
browser.assert.text('span#surname', "Colombo");
browser.assert.elements('span#dates', 1);
done();
});
});
done();
});
// #6
test('Submit the surname "Vespucci" in the HTML form', function (done) {
assert.fail();
done();
});
});
});