describe("root context", function(){ before(function(){ console.log("before: root"); }); beforeEach(function(){ console.log("beforeEach: root"); }); it("test 1", function(){ }); describe("first context", function(){ before(function(){ console.log("\tbefore: first"); }); beforeEach(function(){ console.log("\tbeforeEach: first"); }); it("test first.1", function(){}); it("test first.2", function(){}); after(function(){ console.log("\tafter: first"); }); afterEach(function(){ console.log("\tafterEach: first"); }); }); describe("second context", function(){ before(function(){ console.log("\t\tbefore: second"); }); beforeEach(function(){ console.log("\t\tbeforeEach: second"); }); it("test second.1", function(){}); it("test second.2", function(){}); after(function(){ console.log("\t\tafter: second"); }); afterEach(function(){ console.log("\t\tafterEach: second"); }); }); after(function(){ console.log("after: root"); }); afterEach(function(){ console.log("afterEach: root"); }); }); //results in: //root context //before: root //beforeEach: root //✓ test 1 //afterEach: root //first context //before: first //beforeEach: root //beforeEach: first //✓ test first.1 //afterEach: first //afterEach: root //beforeEach: root //beforeEach: first //✓ test first.2 //afterEach: first //afterEach: root //after: first //second context //before: second //beforeEach: root //beforeEach: second //✓ test second.1 //afterEach: second //afterEach: root //beforeEach: root //beforeEach: second //✓ test second.2 //afterEach: second //afterEach: root //after: second //after: root