Tell us what’s happening:
Describe your issue in detail here.
I can’t pass test 5 and 6 in the 2_functional_tests.js, I get an AssertionError: no open window with html document. I checked the forums and saw that some other people had this exact issue but I could find the right solution. In one of the forums it was suggested to use local resources to pass these challenges. So I tried to download the zip from replit and when I try to run the code in my vs code I get ReferenceError: suite is not defined… Any help would be appricated.
Your code so far
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(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();
});
});
});
});
const Browser = require('zombie');
Browser.site = '0.0.0.0:3000';//'https://boilerplate-mochachai.garikhk.repl.co';
suite('Functional Tests with Zombie.js', function () {
this.timeout(5000);
const browser = new Browser();
suiteSetup(function(done) {
browser.visit('/', done);
});
suite('Headless browser', function () {
test('should have a working "site" property', function() {
assert.isNotNull(browser.site);
});
});
suite('"Famous Italian Explorers" form', function () {
// #5
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.element('span#date', 1);
done();
});
});
});
// #6
test('Submit the surname "Vespucci" in the HTML form', function (done) {
browser.fill('surname', 'Vespucci').then(() => {
browser.pressButton('submit', () => {
browser.assert.success();
browser.assert.text('span#name', 'Amerigo');
browser.assert.text('span#surname', 'Vespucci');
browser.assert.element('span#date', 1);
done();
});
});
});
});
});
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
Challenge: Quality Assurance and Testing with Chai - Run Functional Tests Using a Headless Browser
Link to the challenge: