Skip to content

Instantly share code, notes, and snippets.

@miguelsaddress
Last active August 29, 2015 14:01
Show Gist options
  • Save miguelsaddress/ee744ece9fe58211c81e to your computer and use it in GitHub Desktop.
Save miguelsaddress/ee744ece9fe58211c81e to your computer and use it in GitHub Desktop.
Angular test execution order.
beforeEach( function(){ console.log("Global before each")} );
describe( "Describe 1", function(){
beforeEach( function(){ console.log("Describe 1 - before each 1")} );
beforeEach( function(){ console.log("Describe 1 - before each 2")} );
//do tests...
it("a test...", function(){
//if there is not a "it()", the beforeEach/afterEach does not execute
});
afterEach( function(){ console.log("Describe 1 - after each 1")} );
afterEach( function(){ console.log("Describe 1 - after each 2")} );
});
describe( "Describe 2", function(){
beforeEach( function(){ console.log("Describe 2 - before each 1")} );
beforeEach( function(){ console.log("Describe 2 - before each 2")} );
//do tests...
it("a test...", function(){
//if there is not a "it()", the beforeEach/afterEach does not execute
});
afterEach( function(){ console.log("Describe 2 - after each 1")} );
afterEach( function(){ console.log("Describe 2 - after each 2")} );
});
afterEach( function(){ console.log("Global after each 1")} );
afterEach( function(){ console.log("Global after each 2")} );
LOG: 'Global before each'
LOG: 'Describe 1 - before each 1'
LOG: 'Describe 1 - before each 2'
LOG: 'Describe 1 - after each 2'
LOG: 'Describe 1 - after each 1'
LOG: 'Global after each 2'
LOG: 'Global after each 1'
LOG: 'Global before each'
LOG: 'Describe 2 - before each 1'
LOG: 'Describe 2 - before each 2'
LOG: 'Describe 2 - after each 2'
LOG: 'Describe 2 - after each 1'
LOG: 'Global after each 2'
LOG: 'Global after each 1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment