Run Functional Tests Using a Headless Browser and Run Functional Tests Using a Headless Browser II

i can not pass this two challenges i keep getting the error message
AssertionError [ERR_ASSERTION]: no open window with an html document
here is the link to the project: boilerplate-mochachai - Replit
here is the link to the challenges: #1) run-functional-tests-using-a-headless-browser
#2) run-functional-tests-using-a-headless-browser-ii

thanks in advance.
Also,i notice in the challenge Simulate Actions Using a Headless Browser the hook should be

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

the done method should have a bracket when called in the return statement to pass the challenge.but in the example,it is saying we should use only done.

I would suggest doing this challenge locally. Replit is pretty unreliable with the zombie tests.

Not true, it takes a callback function.

1 Like

Not true, it takes a callback function.

well i think the problem is with the replit platform,like i was saying when i used done with out bracket as suggested in the example it does not work,with bracket it does.will be trying locally,thank you very much.

If you invoke the callback then you are passing the function return value and not the actual callback function.

It might look like it is working because (I assume) you do not get the timeout error, which is the issue running this challenge on Replit often gives. However, that doesn’t mean it works when invoking the callback.

Anyway, running the challenge locally will in my experience always work without issues.

well i tried it locally,but it give me the error for both the last challenges:AssertionError [ERR_ASSERTION]: No INPUT matching 'surname'
does i am the only one having this issue?
here is my code:

const Browser = require('zombie');
Browser.localhost('example.com', (process.env.PORT || 3000));

suite('Functional Tests with Zombie.js', function () {
  this.timeout(5000);
  const browser = new Browser();
  suiteSetup(function(done) {
  return 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.elements('span#dates',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.elements('span#dates',1);
      done();
      });
      });
    });
  });
});

You are still calling done() in browser.visit you have to pass the callback.

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

Your code does pass for me using your setup

Browser.localhost('example.com', process.env.PORT || 3000);

but you can also just set Browser.site to localhost.

Browser.site = '0.0.0.0:3000';

You may have to use 0.0.0.0 instead of localhost or 127.0.0.1, at least I do, which didn’t use to be the case (not sure what changed, it might be a nodejs version thing or something else).

Or when using Browser.localhost you can use browser.proxy to set a different localhost address.

const browser = new Browser();
browser.proxy = 'http://0.0.0.0:3000';
1 Like

i already tried using done only but has get the error "before all" hook in "Functional Tests with Zombie.js": TypeError: bind EINVAL 0.0.0.0
i also updated node and npm to the latest version.
wohoooo,
finally it worked,i can not belieive my eyes.
by setting

@lasjorg:
Browser.site = ‘0.0.0.0:3000’;

thanks a lot i real appreciate your effort and commitment

1 Like

Change the localhost to 0.0.0.0 as I said to, that error is the same I get when using localhost or 127.0.0.1

1 Like

but now FCC is not accepting any of the test results :pensive:,when i give the live url
http://localhost:3000/,the server is not stopped in vscode.tried replacing localhost with 0.0.0.0.

It works just fine for me. Are you getting any errors in the console or the network tab?

It would be easier if you created a GitHub repo and pushed your current code instead of having to post your latest code here on the forum.

Edit: you are using http://localhost:3000 for the URL you submit right?

yes of course ,i am using http://localhost:3000 for the URL to submit.
sorry,i do not now what the problem is in github now,i have been try to add a file to the repo either by draging or choosing the file but it would not let me it just open the file in new tab when i drag and drop .while choosing file nothing happens.
also tried creating new file but the commit button is not working( is highlighted.)
also tried pushing it from vscode terminal but when it asks for authentication,i can not because again the button is not working.

Now might be as good a time as any to learn Git and how to use GitHub. It may seem like a detour but I’d say learning that is way more important than passing this challenge.

I’m sure freeCodeCamp has tutorials on the YouTube channel.


Not sure why the drag-and-drop isn’t working for you. Maybe try zipping the code up and uploading the zip file. If it doesn’t work upload it somewhere else (dropbox, onedrive, whatever).


here is the repo:-

Your code is passing for me.

Please push all the code (gitignore the node_modules folder).

very sorry for the very late reply.i was having some issue with SSH-KEYS and of course some work issue at home :grinning:
i add all the files including the node_modules so,i had to remove it from .gitignore and i think the problem is with this file may be.i followed the same way as suggested in the link you give me to work locally the challenges.should i use nodemon instead to configure the node_modules.also i was having the same issue when i submit Metric-Imperial Converter project to FCC all tests not passing,but locally works,when i provide the localhost url.

Your repo code is passing both challenges you linked to for me.

You don’t want to commit the node_modules folder. As long as you commit the package.json and package-lock.json files anyone can install the dependencies. Add /node_modules to your .gitignore file.

You can use nodemon for development but I would suggest having the main script running node directly.

"scripts": {
  "start": "node server.js",
  "dev": "nodemon server.js"
}

by what,locally or using replit?
i tried using replit by Changing the localhost to 0.0.0.0.it pass one challenge after a lot try but the last one seems not passing even after so much attempts.
well i think i have no other choice but to try another day until it passes.if you see the screenshoot i give you at the top it is not passing any testes or give a time out.so,it seems it is not working totally using locally and remember i did not stop the server while i submit the localhost url.
i commited the node_modules folder because you have mentioned it to push,but if no need i will add it to .gitignore.
also giving the github repo link only for the projects does not seems to work,i need to give both links?

Locally, you do not need it on Replit. Only the certification projects have to be online.

That was the entire point of doing it locally because Replit is awful with the last zombie tests. You should be able to pass all the challenges using the locally running version, maybe you have something on your end that is blocking it somehow because it works without issue for me.

You can’t submit the GitHub repo, the code has to be running on a Node.js server (locally or remotely) so it can be tested.

Just to be clear, you never commit or push the dependencies. Pushing your code does not include the dependencies, only your own code. You should always gitignore the node_modules folder.

thanks a lot @lasjorg,it works now the problem arise because i was using brave browser. i think it blocked the request coming from FCC to test the live server.
so, after using chrome it passes all the test even the Metric-Imperial Converter project,but the submit and go to next challenge not showing up?

Good to hear you figured out the issue.

The Metric-Imperial Converter project is a certificate project, as I said, they have to be online and can not be submitted using a local version (as the message also says).