Quality Assurance and Testing with Chai - Run Functional Tests Using a Headless Browser II

I’ve tried everything but I can’t find the solution to this. I have watched video tutorials and still, I got nothing. I’ve looked arround in forums and still don’t get why the test is failing.

My code goes as follows:

text const Browser = require(‘zombie’);
Browser.site = ‘https://boilerplate-mochachai.goncamarolopes.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 “surname” : “Colombo” - write your e2e test…’, function(done) {

  browser
    .fill('surname', 'Colombo')
    .pressButton('submit', function() {
      browser.assert.success();
      browser.assert.text("span#name", "Cristoforo");
      browser.assert.text("span#surname", "Colombo");
      browser.assert.element("span#dates", 1);
      done();
  });
});
 // #6
test('Submit the surname "Vespucci" in the HTML form', function (done) {
  browser.fill('surname', 'Vespucci').pressButton('submit', function()  {
      browser.assert.success();
      browser.assert.text("span#name", "Amerigo");
      browser.assert.text("span#surname", "Vespucci");
      browser.assert.elements("span#dates", 1);
      done();
  });
});

});
});

This is the error it keeps throwing at me:

"1) Functional Tests with Zombie.js
“Famous Italian Explorers” form
submit “surname” : “Colombo” - write your e2e test…:
AssertionError [ERR_ASSERTION]: No open window with an HTML document
at Browser.field (node_modules/zombie/lib/index.js:598:5)
at Browser.fill (node_modules/zombie/lib/index.js:646:24)
at Context. (tests/2_functional-tests.js:93:10)
at process.processImmediate (node:internal/timers:476:21)

  1. Functional Tests with Zombie.js
    “Famous Italian Explorers” form
    Submit the surname “Vespucci” in the HTML form:
    AssertionError [ERR_ASSERTION]: No open window with an HTML document
    at Browser.field (node_modules/zombie/lib/index.js:598:5)
    at Browser.fill (node_modules/zombie/lib/index.js:646:24)
    at Context. (tests/2_functional-tests.js:104:15)
    at process.processImmediate (node:internal/timers:476:21)"

I’ve read the two last challenges may have a bug and should be skipped but the post was from 3 years ago.
Any help would be greatly appreciated.

Challenge: Quality Assurance and Testing with Chai - Run Functional Tests Using a Headless Browser II

Link to the challenge:

1 Like

done should be used as a callback in the visit method. It should not be invoked.

browser.visit('/', done);

https://replit.com/@goncamarolopes/boilerplate-mochachai

It’ll throw this out if I use

browser.visit(‘/’ , done);

instead of

browser.visit(‘/’, done());

Functional Tests with Zombie.js

  1. “before all” hook in “Functional Tests with Zombie.js”

  2. Functional Tests with Zombie.js
    “before all” hook in “Functional Tests with Zombie.js”:
    Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure “done()” is called; if returning a Promise, ensure it resolves. (/home/runner/boilerplate-mochachai/tests/2_functional-tests.js)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)

1 Like
  • You are missing a .keepOpen() in the fourth test.

  • Your syntax for the last two tests is not correct. Review the code example given.

Thank you very much! Finally got what I had wrong! :fist_right: :fist_left:

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