Run Functional Tests using a Headless Browser and Run Functional Tests using a Headless Browser ||

I just cant pass any Test please help me ?
I am really frustrated, been trying hours to figure it out , (not like you should study , but even tried other peoples solutions after hours of failure )
Can you please have a look and tell me what’s wrong and why it is not passing the any of the tests ?
here is the Link: https://repl.it/@Levo96/Quality-Assurance-and-Testing-with-Chai-Basics#tests/2_functional-tests.js

Thank you

Hi, this issue has been brought up before.

Please check the following thread:

It looks like the issue was closed and merged successfully.

Hello there,

It appears you have not followed the instructions in this lesson quite right: Quality Assurance and Testing with Chai - Simulate Actions Using a Headless Browser | Learn | freeCodeCamp.org

The tests hint at this, when you run them in Repl.it:

I recommend you redo the lessons from that point. Do be careful, the tests (fCC) for the above mentioned lesson are very lax (will pass with almost anything)

Hope this helps

I just cant find the error , what should i do ?

More of a hint:

Here is your code where the error is:

const browser = new Browser();

suiteSetup(function(done) {
  return browser.visit('/', done);
});



suite("Functional Tests with Zombie.js", function () {
  
  suite('"Famous Italian Explorers" form', function () {
    // #5

Here are the instructions (read them carefully):

Within tests/2_functional-tests.js , at the root level of the 'Functional Tests with Zombie.js' suite, instantiate a new instance of the Browser object with the following code:

const browser = new Browser();

Then, use the suiteSetup hook to direct the browser to the / route with the following code:

suiteSetup(function(done) {
  return browser.visit('/', done);
});

Hope this helps

1 Like

still won’t work can someone just send me the solution pls ?

It appears you have copied code used from a while back. The challenge has recently been updated, so old code is unlikely to work.

I really suggest you go through the functional section from scratch. Copy-paste this boilerplate 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 () {
  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.fail(res.status, 200);
          assert.fail(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.fail(res.status, 200);
          assert.fail(res.text, "hello xy_z");
          done();
        });
    });
    // #3
    test('send {surname: "Colombo"}', function (done) {
      chai
        .request(server)
        .put("/travellers")

        .end(function (err, res) {
          assert.fail();

          done();
        });
    });
    // #4
    test('send {surname: "da Verrazzano"}', function (done) {
      assert.fail();

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

const Browser = require("zombie");

suite("Functional Tests with Zombie.js", function () {

  suite('"Famous Italian Explorers" form', function () {
    // #5
    test('submit "surname" : "Colombo" - write your e2e test...', function (done) {
      browser.fill("surname", "Colombo").pressButton("submit", function () {
        assert.fail();

        done();
      });
    });
    // #6
    test('submit "surname" : "Vespucci" - write your e2e test...', function (done) {
      assert.fail();

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

It will be beneficial for you to slowly go through the lessons and instructions.

Hope this helps