Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Jest order of operations
describe( 'level 0', () => {
beforeAll( () => console.log( 'beforeAll', 'Level 0' ) );
afterAll( () => console.log( 'afterAll', 'Level 0' ) );
beforeEach( () => console.log( 'beforeEach', 'Level 0' ) );
afterEach( () => console.log( 'afterEach', 'Level 0' ) );
describe( 'level 1A', () => {
beforeAll( () => console.log( 'beforeAll', 'Level 1A' ) );
afterAll( () => console.log( 'afterAll', 'Level 1A' ) );
beforeEach( () => console.log( 'beforeEach', 'Level 1A' ) );
afterEach( () => console.log( 'afterEach', 'Level 1A' ) );
it( 'level 1A test 1', () => console.log( 'level 1A test 1' ) );
it( 'level 1A test 2', () => console.log( 'level 1A test 2' ) );
} );
describe.only( 'level 1B', () => {
beforeAll( () => console.log( 'beforeAll', 'Level 1B' ) );
afterAll( () => console.log( 'afterAll', 'Level 1B' ) );
beforeEach( () => console.log( 'beforeEach', 'Level 1B' ) );
afterEach( () => console.log( 'afterEach', 'Level 1B' ) );
it( 'level 1B test 1', () => console.log( 'level 1B test 1' ) );
it( 'level 1B test 2', () => console.log( 'level 1B test 2' ) );
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment