Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fatso83/mini-mocha

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fatso83/mini-mocha

A minimal emulation of Mocha

  • 2.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

mini-mocha

An absolutely minimal emulation of Mocha for demos.

Why

This was hacked together very quickly for demo purposes, making it possible to verify bugs on the Sinon issue tracker without having access to a development environment. Having an API emulation of Mocha makes it easier to demo bugs on RunKit when I see a verification test using Mocha or Jasmine, as I can just copy-paste the test into RunKit, add require('@fatso83/mini-mocha').install() at the top and it will run!

Typical usage

require('@fatso83/mini-mocha').install();

describe("issue #101 ES5 version", function() {
    it("shows a normal sync test", function() {
        // passes
    });

    it("will fail", function() {
        throw new Error("My error");
    });

    it("shows a normal async test using callbacks", function(done) {
        setTimeout(() => {
            done();
        });
    });

    it("will fail async", function(done) {
        setTimeout(() => {
            done(new Error("My error"));
        });
    });
});

Results in this being printed

$ node demo.js

issue #101 ES5 version
✔️  shows a normal sync test
❌ will fail (Failed with: "My error")
✔️  shows a normal async test using callbacks
❌ will fail async (Failed with: "My error")

async/await (aka Promises) feature
✔️  should pass as expected
❌ should fail (Failed with: "Some wrong type")

Known limitations

There are bits and pieces missing from the Mocha API, but it fulfills all the basic requirements.

  • No support for Mocha internals like this.title, this.fullTitle(), etc.

Pull requests welcome :)

If you want to contribute, here are some tips:

  • npm run update-snapshots will update the snapshots used for testing the output

Keywords

FAQs

Package last updated on 30 Jan 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc