Nutrias Punching Marmots
Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

mocha-steps

1.3.0 • Public • Published

mocha-steps

Sequential scenarios for Mocha

NPM License

Build Status

Dependencies Dev dependencies

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 install mocha-steps --save-dev

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
   - temporarily ignored
  • Using step()
my smoke test
   ✓ login
   ✗ buy an item
   - check my balance
   - temporarily ignored

Notes

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

When submitting a PR, please run ./test.sh and implement new test cases if required.

install

npm i mocha-steps

Downloadsweekly downloads

4,014

version

1.3.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability