Socket
Socket
Sign inDemoInstall

mocha-bdd-extend

Package Overview
Dependencies
71
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mocha-bdd-extend

Extend BDD Interfaces for Mocha


Version published
Maintainers
1
Created

Readme

Source

mocha-bdd-extend

Extend BDD Interfaces for Mocha

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

Setup

Then simply run mocha with --require mocha-bdd-extend --ui bdd-extend.

Example

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

  step('open page', function() {});

  step('switch test case', function() {});

  step('check element is exists', function() {
    // switch test case to enable
    changePending.call(this, 'check pending test case', false);
  });

  step('check pending test case', function() {});

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

  step('buy item', function() {});
  
  xstep('ignored step', function() {});

  // switch off test to pending
  changePending('switch test case', true);
  changePending('check pending test case', true);
});
  • With the standard it()
my smoke test
   ✓ open page
   ✗ select item
   ✓ buy item
  • Using step()
my smoke test
   ✓ open page
   ✗ select item
   - switch test case
   ✓ check element is exists
   ✓ check pending test case
   - buy item (abort all suites)

Notes

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

Keywords

FAQs

Last updated on 25 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc