To accomplish this I define a common function and then refer to it in the beforeAll
/afterAll
of each nested describe
.
describe('Wrapper', function() {
var _startup = function(done) {
login();
window.setTimeout(done, 150);
};
var _shutdown = function() {
logout();
};
describe('Inner 1', function() {
beforeAll(_startup);
afterAll(_shutdown);
});
describe('Inner 2', function() {
beforeAll(_startup);
afterAll(_shutdown);
});
describe('Inner 3', function() {
beforeAll(_startup);
afterAll(_shutdown);
});
});
It seems to be cleanest solution available.