I ran into a problem recently that I can\'t explain. I have alot of code in these tests so I\'m going to do my best to capture the idea here
I have tests that look li
Mocha's test runner explains this functionality the best in the Hooks section of the Mocha Test Runner.
From the Hooks section:
describe('hooks', function() {
before(function() {
// runs before all tests in this file regardless where this line is defined.
});
after(function() {
// runs after all tests in this file
});
beforeEach(function() {
// runs before each test in this block
});
afterEach(function() {
// runs after each test in this block
});
// test cases
});
You can nest these routines within other describe blocks which can also have before/beforeEach routines.