Run Functional Tests on an API Response using Chai-HTTP IV - PUT method (`SyntaxError: Unexpected end of input.`)

Tell us what’s happening:
I am doing part IV of Run Functional Tests on an API Response using Chai-HTTP - PUT method. Everything is crisp until I click the Run button on my Replit and I get this error: SyntaxError: Unexpected end of input.

I copied and pasted all the indentation and syntax from the last task (part III of Run Functional Tests on an API Response using Chai-HTTP - PUT method) and simply changed what needed to be changed for the current task.

I check the end of input and there’s a tilde(~) underlined in red. I haven’t made any edits to any of the code that follows the current task.

Here is my 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)
        .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=rajab')
        .end(function (err, res) {
          assert.equal(res.status, 200);
          assert.equal(res.text, 'hello rajab');
          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, '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 "Christoforo"'
      );
          assert.equal(
        res.body.surname,
        'Colombo',
        'res.body.surname should be "Colombo"'
      );

          done();
        });
    });

    // #4
    test('Send {surname: "da Verrazzano"}', function (done) {
      assert.fail();
test('Send {surname: "Colombo"}', 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 Verrazano"'
      );

      done();
    });
  });
});

const Browser = require('zombie');

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



  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) {
      assert.fail();

      done();
    });
    // #6
    test('Submit the surname "Vespucci" in the HTML form', function (done) {
      assert.fail();

      done();
    });
  });
});

Your project link(s)

solution: https://replit.com/@rjkawoya/boilerplate-mochachai-4

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36

Challenge: Run Functional Tests on an API Response using Chai-HTTP IV - PUT method

Link to the challenge:

Make sure you use proper formatting and indentation. Use the tidy function in Replit.

Time for hunt the missing parentheses and brackets. What I usually do is bring the code into an editor with better syntax highlighting like VS Code. Then start at the top and work your way down. Do not make the mistake of thinking that the syntax error is near the error indication, syntax errors cascade down. A mistake hundred lines up can cause an error to show up at the bottom of the code.

You didn’t close the two initial functions correctly (or you used the closing code for the last test and end).

suite('Functional Tests', function () {
  this.timeout(5000);
  suite('Integration tests with chai-http', function () {
  

  });
});

There should be 4 }); before const Browser = require('zombie');


Just as an aside, you are not sending the correct JSON.