Option 1
I would suggest using nesting your describes, e.g.:
describe('1', function () {
describe('1 to 4', function () {
beforeEach(function () {
// do this before each it EXCEPT 1.5
});
it('1.1', function () {
});
it('1.2', function () {
});
it('1.3', function () {
});
it('1.4', function () {
});
});
describe('only 5', function () {
it('1.5', function () {
// beforeEach shouldn't run before this
});
});
Behind the scenes describe will register the beforeEach function which will get called for all itFunctions if it exists.
Option 2
The it functions will be called sequentially so you could also use a closure to control when beforeEach gets run - but it's a bit hacky - e.g.:
describe('1', function () {
var runBefore = true
beforeEach(function () {
// do this before each it EXCEPT 1.5
if (runBefore) {
// actual code
}
});
// functions removed for brevity
it('1.4', function () {
runBefore = false;
});
it('1.5', function () {
// beforeEach shouldn't run before this
// turn it back on for 1.6
runBefore = true;
});
});