Created
December 12, 2014 17:14
-
-
Save corywheeler/73dd40d89d417758fb2e to your computer and use it in GitHub Desktop.
Show the order of execution of mocha's before and beforeEach hooks for each describe and each test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('highest level describe', function () { | |
before(function() { | |
console.log('This is the highest level before') | |
}) | |
beforeEach(function() { | |
console.log('This is the highest level beforeEach') | |
}) | |
it('This is the first highest level test', function() { | |
console.log('first highest level test') | |
true; | |
}) | |
it('This is the second highest level test', function() { | |
console.log('second highest level test') | |
true; | |
}) | |
describe('nested describe', function() { | |
before(function() { | |
console.log('This is the nested before') | |
}) | |
beforeEach(function() { | |
console.log('This is the nested beforeEach') | |
}) | |
it('This is the first nested test', function() { | |
console.log('first nested test') | |
true; | |
}) | |
it('This is the second nested test', function() { | |
console.log('second nested test') | |
true; | |
}) | |
describe('a nested\'s nested', function() { | |
before(function() { | |
console.log('This is the nested\'s nested before') | |
}) | |
beforeEach(function() { | |
console.log('This is the nested\'s nested beforeEach') | |
}) | |
it('This is the first nested\'s nested test', function() { | |
console.log('first nested\'s nested test') | |
true; | |
}) | |
it('This is the second nested\'s nested test', function() { | |
console.log('second nested\'s nested test') | |
true; | |
}) | |
}) | |
}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
highest level describe | |
This is the highest level before | |
This is the highest level beforeEach | |
first highest level test | |
√ This is the first highest level test | |
This is the highest level beforeEach | |
second highest level test | |
√ This is the second highest level test | |
nested describe | |
This is the nested before | |
This is the highest level beforeEach | |
This is the nested beforeEach | |
first nested test | |
√ This is the first nested test | |
This is the highest level beforeEach | |
This is the nested beforeEach | |
second nested test | |
√ This is the second nested test | |
a nested's nested | |
This is the nested's nested before | |
This is the highest level beforeEach | |
This is the nested beforeEach | |
This is the nested's nested beforeEach | |
first nested's nested test | |
√ This is the first nested's nested test | |
This is the highest level beforeEach | |
This is the nested beforeEach | |
This is the nested's nested beforeEach | |
second nested's nested test | |
√ This is the second nested's nested test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment