<commit_before># Meta:Magical Mocha Bridge

[![NPM version](https://img.shields.io/npm/v/metamagical-example-testing.svg?style=flat-square)](https://npmjs.org/package/metamagical-example-testing)
![Licence](https://img.shields.io/npm/l/metamagical-example-testing.svg?style=flat-square&label=licence)
![Stability: Stable](https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square)

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


## Example

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

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

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

Then use this module inside a Mocha test:

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

defineTests(double);
```


## 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.

```shell
$ npm install metamagical-mocha-bridge
```

[npm]: https://www.npmjs.com/
[Node.js]: nodejs.org



## 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](https://github.com/origamitower/metamagical/issues).

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](https://gitter.im/origamitower/discussion) for
quick support. You may also contact the author directly through
[email](mailto:<EMAIL>), or
[Twitter](https://twitter.com/robotlolita).

Note that all interactions in this project are subject to Origami Tower's
[Code of Conduct](https://github.com/origamitower/metamagical/blob/master/CODE_OF_CONDUCT.md).


## Licence

Meta:Magical is copyright (c) <NAME> 2016, and released under the MIT licence. See the `LICENCE` file in this repository for detailed information.<commit_msg>(- mocha doc) Explains the use of assertion comments plugin in examples<commit_after># Meta:Magical Mocha Bridge

[![Chat on Gitter](https://img.shields.io/gitter/room/origamitower/discussion.svg?style=flat-square)](https://gitter.im/origamitower/discussion) 
[![Build status](https://img.shields.io/travis/origamitower/metamagical/master.svg?style=flat-square)](https://travis-ci.org/origamitower/metamagical) 
[![NPM version](https://img.shields.io/npm/v/metamagical-mocha-bridge.svg?style=flat-square)](https://npmjs.org/package/metamagical-mocha-bridge)
![Licence](https://img.shields.io/npm/l/metamagical-mocha-bridge.svg?style=flat-square&label=licence)
![Stability: Stable](https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square)

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


## Example

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

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

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

Then use this module inside a Mocha test:

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

defineTests(double);
```

If you use the [Babel assertion comments plugin](../babel-plugin-assertion-comments), you can write this instead:

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

double[Symbol.for('@@meta:magical')] = {
  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.

```shell
$ npm install metamagical-mocha-bridge
```

[npm]: https://www.npmjs.com/
[Node.js]: nodejs.org


## 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](https://github.com/origamitower/metamagical/issues).

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](https://gitter.im/origamitower/discussion) for quick support.
You can contact the author over [email](mailto:<EMAIL>), or
[Twitter](https://twitter.com/robotlolita).

Note that all interactions in this project are subject to Origami Tower's
[Code of Conduct](https://github.com/origamitower/metamagical/blob/master/CODE_OF_CONDUCT.md).


## Licence

Meta:Magical is copyright (c) <NAME> 2016, and released under the MIT licence. See the `LICENCE` file in this repository for detailed information.
{'fraction_non_alphanumeric': 0.13695987654320987, 'fraction_numerical': 0.006558641975308642, 'mean_word_length': 4.806270996640538, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 20, 'https://': 22, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6936600', 'n_tokens_mistral': 1785, 'n_tokens_neox': 1640, 'n_words': 489}