Quality Assurance and Testing with Chai - Run Functional Tests Using a Headless Browser I &II -- One of the tests keeps failing

Hi there,
I’ve been trying to resolve this issue for the past 3 hours, searched on the forums, tried different ways but I still keep failing the span#dates test on the two last exercises of the QA course, see pics below:


Here’s my code for the whole headless browser suite, which includes the #5 and #6 (the last two) exercises:

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

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

I’d appreciate help/tips on how to finally complete the challange.

I believe you have the wrong method element vs elements

Thanks for the reply.

I wouldn’t agree. The method I used for the element assertion follows the instructions provided for the task, see link here or the snapshot below

The example you posted an image of is using elements not element (which is what you have in your code).

Also, if you look at the docs I posted and the APIs for the two methods you can see which arguments they take, and element does not take a count.

assert.element(selection, message)
assert.elements(selection, count, message)

Thanks for pointing that out!

Although, that solved the issue of the last test not passing, now I’ve encountered another problem:

The last test passes, however, “all tests should pass” point fails.
This has brought even more confusion.

I’ll continue my search on the forums, in case someone had encountered a similar problem.
However, everyone is welcome to reply with a potential solution to the problem here too.

How/where are you running the code? Please post your full code (Replit, GitHub repo, or whatever you are using).

Replit is notoriously bad with the Zombie tests (they crash and timeout) but if you run them locally they should pass with no problems.

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