[SOLVED] QA & Testing with Chai - Simulate Actions Using a Headless Browser

Hello fellow Campers

Short version: I think I’ve done exactly what the instructions say, step by step, and I can’t figure out what it is that is not working. Read through several forum posts and haven’t found a solution, lots of people’s code looks the same as mine. Stuck for about an hour already and saw user complain about the instructions omitting something, but no one ever replied to him ( https://forum.freecodecamp.org/t/simulate-actions-using-a-headless-browser-how-am-i-to-solve-this/447408 ).

My code (commented out are the fCC instructions step by step):

const Browser = require('zombie');
// immediately after the Browser declaration, add your project URL to the site property of the variable:
// Browser.site = 'http://localhost:3000';

Browser.site="http://localhost:3000/"; 

//Then 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();
suite('Functional Tests with Zombie.js', function () {
  this.timeout(5000);
  const browser = new Browser();
// And use the suiteSetup hook to direct the browser to the / route with the following code:
//  suiteSetup(function(done) {
//    return browser.visit('/', done);
//  });
  suiteSetup(function(done) {
  return browser.visit('/', done);
});
// NOTE: I also tried using `return browser.visit('http://localhost:3000/', done);` just in case that did something, but no result

  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();
    });
  });
});

The fCC error message is “All tests should pass.”
The VSCode terminal reads:

Functional Tests with Zombie.js
    1) "before all" hook in "Functional Tests with Zombie.js"
  22 passing (666ms)
  1 failing
  1) Functional Tests with Zombie.js
       "before all" hook in "Functional Tests with Zombie.js":
     TypeError: bind EINVAL 0.0.0.0`

The page doesn’t say anything about tests #5 and #6, and those are completed in the next two exercises, so I’m assuming I should not touch them yet. So, am I missing something, or are the instructions missing something, or are there any other issues at play?

As always, thank you to anyone who takes the time to read and/or reply.

Your browser information:

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

Challenge Information:

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

Finally found a solution in the forum:

The instructions tell students to add

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

but the second done is missing parenthesis and should be done()

Could someone at fCC please correct the instructions for future students? Thanks in advance.

2 Likes

Spent couple of days searching for the problem and reading the documentation only to find it here. @freeCodeCamp Kindly look into this.

2 Likes

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