metamagical-mocha-bridge
Allows defining Mocha test cases from Meta:Magical examples.
Last updated 3 years ago by robotlolita .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install metamagical-mocha-bridge 
SYNC missed versions from official npm registry.

Meta:Magical Mocha Bridge

Chat on Gitter Build status NPM version Licence Stability: Stable

This package allows defining Mocha test cases from Meta:Magical examples.

Example

Annotate some object with Meta:Magical using the examples meta-data:

function double(n) {
  return n + n;
}

double[Symbol.for('@@meta:magical')] = {
  name: 'double',
  examples: [_ => {
    var assert = require('assert');
    assert(double(10) === 20);
    assert(double(15) === 30);
  }]
}

Then use this module inside a Mocha test:

const metamagical = require('metamagical-interface');
const defineTests = require('metamagical-mocha-bridge')(metamagical, describe, it);

defineTests(double);

NOTE
metamagical-mocha-bridge only runs tests for named objects.

If you use the Babel assertion comments plugin, you can write this instead:

function double(n) {
  return n + n;
}

double[Symbol.for('@@meta:magical')] = {
  name: 'double',
  examples: [_ => {
    double(10); // ==> 20
    double(15); // ==> 30
  }]
}

Installing

The only supported way to install the transform plugin is through npm.

NOTE
If you don't have npm yet, you'll need to install Node.js. All newer versions (4+) of Node come with npm.

$ npm install metamagical-mocha-bridge

Support

If you think you've found a bug in the project, or want to voice your frustration about using it (maybe the documentation isn't clear enough? Maybe it takes too much effort to use?), feel free to open a new issue in the Github issue tracker.

Pull Requests are welcome. By submitting a Pull Request you agree with releasing your code under the MIT licence.

You can join the Gitter Channel for quick support. You can contact the author over email, or Twitter.

Note that all interactions in this project are subject to Origami Tower's Code of Conduct.

Licence

Meta:Magical is copyright (c) Quildreen Motta 2016, and released under the MIT licence. See the LICENCE file in this repository for detailed information.

Current Tags

  • 0.4.0                                ...           latest (3 years ago)

5 Versions

  • 0.4.0                                ...           3 years ago
  • 0.3.0                                ...           4 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 8
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |