Skip to content

Instantly share code, notes, and snippets.

@rbartoli
Last active June 16, 2016 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbartoli/e3099ca5b0704e477a86 to your computer and use it in GitHub Desktop.
Save rbartoli/e3099ca5b0704e477a86 to your computer and use it in GitHub Desktop.
describe( 'Top level suite', function() {
describe( 'Second level test suite', function() {
before( function() {
// executes once, before all tests
} );
beforeEach( function() {
// executes before each test of the suite
} );
after( function() {
// executes once, after all tests
} );
afterEach( function() {
// executes after each test of the suite
} );
it( 'should verify a behavior', function() {
// a test containing assertions
} );
it('should verify an async behaviour', function() {
setTimeout(() => {
try {
// expect here
done()
} catch(e) {
done(e)
}
}, 100)
})
xit( 'should be a pending test', function() {
// this test is pending. All assertions inside are ignored.
} );
it.skip( 'should also be a pending test', function() {
// it.skip is a longer, more semantic form of xit
} );
it( 'should also be a pending test' );
} );
describe( 'Another second level test suite', function() {
} );
} );
describe( 'Maintainable unit test cases...', function( ) {
it( 'should test one type of behavior' );
it( 'should not depend on any other test cases.' );
it( 'should execute with exact same initial state as any other tests in the suite.' );
it( 'should not matter in which order are these tests executed.' );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment