Skip to content

umbrew/mocha-steps

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mocha-steps

Sequential scenarios for Mocha

Global step() function, as a drop-in replacement for it(). Any failing step will abort the parent describe immediately. This is handy for BDD-like scenarios, or smoke tests that need to run through specific steps.

Setup

NPM

Then simply run mocha with --require mocha-steps.

Example

describe('my smoke test', function() {

  step('login', function() {
  });

  step('buy an item', function() {
    throw new Error('failed');
  });

  step('check my balance', function() {
  });
  
  xstep('temporarily ignored', function() {
  });

});
  • With the standard it()
my smoke test
   ✓ login
   ✗ buy an item
   ✓ check my balance
  • Using step()
my smoke test
   ✓ login
   ✗ buy an item

Notes

  • Unlike Mocha's --bail option, the rest of the test suite will run normally.
  • step() works with synchronous, async, and promise tests.

About

Sequential scenarios for mocha

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%