Quality Assurance and Testing with Chai - Simulate Actions Using a Headless Browser

Tell us what’s happening:
Describe your issue in detail here.

despite my code seems correct (all the tests pass) when i submit it i can’t go ahead to the next chapter. can somebody help? here is the code:

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)
        .keepOpen()
        .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)
        .keepOpen()
        .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)
        .keepOpen()
        .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)
        .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();
        });
    });
  });
}); // Add this line

const Browser = require('zombie');
Browser.site = 'https://boilerplate-mochachai--francesco15.repl.co/'; // Your URL here

suite('Functional Tests with Zombie.js', function () {
  this.timeout(5000);

  const browser = new Browser();
  suiteSetup(function(done) {
    browser.visit('/', done);
  });

  suite('Headless browser', function () {
    // #5 test case...
  });

  suite('"Famous Italian Explorers" form', function () {
    // #6 test case...
  });
});

Your browser information:

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

Challenge: Quality Assurance and Testing with Chai - Simulate Actions Using a Headless Browser

Link to the challenge:

Hi there and welcome to the forum!

I think you may have accidentally deleted the following code when you were adding in the new code:

suite('Headless browser', function() {
    test('should have a working "site" property', function() {
      assert.isNotNull(browser.site);
    });
  });

It should sit directly above this code:

suite('Headless browser', function () {
    // #5 test case...
  });

Stick it back in and I think your code should pass!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.