Run Functional Tests Using a Headless Browser: No open window with an HTML document

Hi,

I note from previous forum posts that there had previously been an issue in the final two challenges of Quality Assurance and Testing with Chai:

I’m still running into issues, with the following console errors:
Untitled

Here’s a link to my repl code:
https://replit.com/@igorgetmeabrain/boilerplate-mochachai#tests/2_functional-tests.js

Can anyone tell me what I’m doing wrong please? Thanks!

1 Like

Hello there,

You appear to have changed code you should not have. I suggest paying close attention to the way the example is laid out. Specifically:

test('Submit the surname "Polo" in the HTML form', function (done) {

Hope this helps

1 Like

Thanks for your reply. I had changed the placement of the parentheses, following advice from another forum post. I have now changed the code back again but still the same issue.
It’s the setting up of the headless browser which appears to be failing, not the tests which follow…

Double-check you followed this lesson’s instructions:

I rebuilt the whole thing from scratch. I passed the initial headless browser challenge (again) but consistently fail the next challenge with the same error as before.
Strangely, I get the following on FCC…

Would you mind sharing your latest code?


What I was getting at in my previous reply is that you should not have suiteSetup within a test callback.

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

When the suiteSetup function is here, the initial headless browser challenge passes. When I move it anywhere outside the test callback, it fails and I get timeout errors in the console.

My current code: https://replit.com/@igorgetmeabrain/boilerplate-mochachai#tests/2_functional-tests.js:2:6

For instance, the following code:

const Browser = require('zombie');
Browser.site = 'https://boilerplate-mochachai.igorgetmeabrain.repl.co';

suite('Functional Tests with Zombie.js', function() {
  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();
        });
      });
    });

  });

Gives the following console errors:

I would suggest you do the challenge locally.

The last Zombie tests consistently pass for me locally but fail very often on Replit. Usually with the page crashing and a timeout error. It seems to have something to do with how Zombie is interacting with the site.

1 Like

Yes, my code worked perfectly, as soon as I ran it locally. Thank you!

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