A suite can have a `beforeEach()` declaration. It takes a function that is run before each spec. For example:
describe('some suite', function () {
var suiteWideFoo;
beforeEach(function () {
suiteWideFoo = 1;
});
it('should equal bar', function () {
expect(suiteWideFoo).toEqual(1);
});
});
A runner can also have `beforeEach()` declarations. Runner `beforeEach()` functions are executed before every spec in all suites, and execute BEFORE suite `beforeEach()` functions. For example:
Similarly, there is an `afterEach()` declaration. It takes a function that is run after each spec. For example:
describe('some suite', function () {
var suiteWideFoo;
afterEach(function () {
suiteWideFoo = 0;
});
it('should equal 1', function () {
expect(suiteWideFoo).toEqual(1);
});
it('should equal 0 after', function () {
expect(suiteWideFoo).toEqual(0);
};
});
A runner can also have an `afterEach()` declarations. Runner `afterEach()` functions are executed after every spec in all suites, and execute AFTER suite `afterEach()` functions. For example:
A spec may ask Jasmine to execute some code after the spec has finished running; the code will run whether the spec finishes successfully or not. Multiple after functions may be given.