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

I typed the correct code. In the first test it was showing almost correct but later it’s showing complete error

Your project link(s)

solution: boilerplate-mochachai - Replit

Your browser information:

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

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

Link to the challenge:

Firstly, you haven’t put the ‘after’ code at the bottom of your functional-tests file.
Again, you’ve put it in between code blocks. Put it at the very BOTTOM, after ALL other code.

Like this:

    // #6
    test('Submit the surname "Vespucci" in the HTML form', function(done) {
      assert.fail();

      done();
    });
  });
});

after(function() {
  chai.request(server)
  .get('/')
});

Secondly, you’re closing off your test suites incorrectly.

suite('Functional Tests with Zombie.js', function() {

This test suite should be closed off at the end of your code (just before the ‘after’ code).
The other test suites which follow the above line of code should be nested inside this one.

What you have done is completely close off all test suites as you go along, which means that your browser declaration is not recognised.

Note that the above line of code is flush with the LHS of the page (i.e. not indented).
Each other test suite below it should be indented and only closed off in line with that indentation.

Inside each of those test suites you have tests which are further indented and closed off to their indentation lines.

Finally, after all of the indented tests suites (each closed off to their indentation lines), you can close off the ‘Functional Tests with Zombie.js’ suite which contains them all, by adding closing brackets which are flush with the original line of code.

So, remove the additional closing off brackets from your other tests suites and make sure that you’re closing each off only to their indentation line, not closing off anything else in the process.

Do you see why indentation is so important?

Done. It is working. Thank you very much.

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