Any of these functions that you run before any or all your tests can be asynchronous. If a function is asynchronous, simply accept a callback argument like this one:
describe('some feature', function() {
function runBeforeEach(done) {
console.log('running afterEach function...');
setTimeout(done, 1000);
}
beforeEach(runBeforeEach);
it('should do A', function() {
console.log('test A');
});
it('should do B', function() {
console.log('test B');
});
});
When running this test code, you will notice the one-second lag before running each test, which—had we not provided the callback argument—would not have been observed.