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?