Skip to content

Instantly share code, notes, and snippets.

@amcdnl
Last active June 30, 2020 05:44
Show Gist options
  • Save amcdnl/a9d8038c54e8bf1cd89657a93d01e9d4 to your computer and use it in GitHub Desktop.
Save amcdnl/a9d8038c54e8bf1cd89657a93d01e9d4 to your computer and use it in GitHub Desktop.

Tape vs Mocha

What is Mocha? Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser.

What is Tape? Tape is a tap-producing test harness for node and browsers

Comparision

Features

Feature Tape Mocha
Assertion Built-in Ifs Agnostic (Chai/Jasmine)
Reporters Tap, Spec, JSON, XUNIT Tap, Spec, JSON, XUNIT
Browser Yes Yes
Parallel Exec Monkey patch Yes
Before/After Monkey patch Yes
Tooling - Wallaby.js, Webstorm, Atom
Promise NA Yes
Diffs Req Module Yes
Test Suite Org No Yes
Code COV Yes, Istabul Yes, Istabul

Popularity

compare

Examples

Tape

import test from 'tape';

test('It should be equal', (asset) => {
  asset.equal(1, 1, 'these two numbers are equal');
  asset.end();
});

Mocha

var assert = require('chai').assert;

describe('Test Suite - Demo', () => {
  it('It should be equal', () => {
    assert.equal(1, 1);
  })
})

Review

Tape is very simple runner that produces TAP output ( https://en.wikipedia.org/wiki/Test_Anything_Protocol ). It lacks many advanced features and editor tooling but wins in terms of simplicity. Many of the features it lacks can be hacked via monkey patching or third-party modules. Tape is geared mostly towards Node testing.

Mocha is a feature-rich test runner that is very popular. It comes out of the box with most features required for advanced testing. Its popularity has driven vendors to write editor tooling as first-class citizens. Mocha is widely adopted on both frontend, backend and qa testing frameworks.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment