Socket
Socket
Sign inDemoInstall

mecha

Package Overview
Dependencies
71
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mecha

Ensure your node examples/*.js work by using them as mocha tests.


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Install size
4.84 MB
Created
Weekly downloads
 

Readme

Source

mecha

Ensure your node examples/*.js work by using them as mocha tests.

Setup

Add mecha to your package.json devDependencies

npm install

Usage

Now your example files can use mocha when run.

// This is my awesome project example at examples/awesome.js
var mecha = require('mecha');

// use `describe' and `it`
mecha.log("This will be printed only when run directly as an example");

// when run as an example use a dot reporter, if no argument is given
// a silent reporter will be used.
mecha({reporter: 'dot'});

Users run your example, and see the message printed above

node examples/awesome.js

But when run as a test, they see test reports.

mocha examples/awesome.js

You can therefore include your example files to your test harness, add a test/examples.js file to your project

// Ensure all examples are working
require('../examples/awesome')

FAQs

Last updated on 25 Aug 2012

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