<commit_before># Reasoning

Mu-mocha is a wrapper around Mocha-test runner. The main design principles are:

1. **Less boilerplate**. While Mocha (and other BDD-frames) is generally less verbose
than TDD traditionally, there's still quite a lot boilerplate code that is not
necessary. Mu-mocha tries to reduce amount of boilerplate code.
2. **Context driven approach**. In the most popular test frameworks, the background
presupposition seems to be that the optimal way to unit test code is more or
lest the same in all cases. Usually, test frameworks are not easy to extend
so that testing different types of code would be as simple as possible. The most
popular frameworks also lack simple and efficient way to write data driven tests.

Mu-mocha makes data driven testing easier and allows you to write your own test builder
that makes testing of your code as simple as possible.


# Installing Mu-mocha

In order to use Mu-mocha you need to take care of two things:

1. Ensure that you can use ES6 in tests. There are many ways to take care of this.
Mu-mocha uses Babel and I instruct you to use it, but you can use another approach.
2. Install and configure Mocha. Then install Mu-mocha .
3. Ensure you have configured mocha to seek the test from correct place.

**Step 1.**  Install Babel (or enable use of ES6 in tests in another way.)

First install Babel from npm:
```
npm install babel --save-dev
```

Then run Mocha with ```--compilers js:babel/register``` switch.

You can also add this to packages.json or use any other mocha compatible build tool
like Gulp, Grunt or WebPack. Internally Mu-mocha uses npm script for tests.

```
"scripts": {
  "test": "mocha --compilers js:babel/register"
},
```

**Step 2.** Install Mocha and Mu-mocha by using npm:

```
npm install mocha --save-dev
npm install mu-mocha  --save-dev
```

**Step 3.** Ensure you have configured Mocha to seek the test from correct place.

By default Mocha seeks test from test folder. If you go with the default create
test folder for your tests.

You can also configura mocha to seek tests by file name pattern (e.g. seek files by pattern *.spec.js)

# Getting started

## Basic usage

You just need to pass and object to run Mu-mocha's ```test``` function.

```
var test = require('mu-mocha ').test,
    expect = require('chai').expect

test({
  "This is Mu-mocha descriptions": {
    "This is Mu-mocha test name":    () => expect(true).to.be.true,
    "This is inner description block": {
      "This is another Mu-mocha test": () => expect(true).to.be.true,  
    }
  }
})
```


This is same as:
```
describe("This is Mocha descriptions", function(){
  it("This is Mocha test name", function(){
    expect(true).to.be.true
  })
  describe("This is inner description block, function(){
    it("This is another Mocha test", function(){
      expect(true).to.be.true
    })
  })
})
```

## How it works

Mocha build a test tree that have two kind of nodes: describe (or context)
nodes and tests. In Mocha you build an expression tree by using describe- and
it-functions. describe and it are actually global functions that executes
that expression three you past to them as parameters.

In in Mu-mocha you use have this information in an object graph. Minimal
mocha converts an object graph into Mocha's function and then and Mocha test
runner takes care of everything else.

In practice Mu-mocha's ```test```-function loops through the all object's
attributes recursively, and converts them into mocha function calls.

There are two main rules:

1. Attributes have a function as are actual tests, what will be converted into
it-function calls. With one exception:
  1. If attribute name is after, afterEach, before, or beforeEach it will be
  converted into the corresponding Mocha test hook functions. I.e. if you need to have
  tests which name is 'after', 'afterEach', 'before' or 'beforeEach', don't use
  Minimal  Mocha - write them with Mocha instead.
2. Attributes that have an object as its value are description nodes. There is an exception to this rule:
  1. if object have both 1) ```data``` and 2) ```test``` attributes, it will be converted into a test. (Notice: ```test``` attribute must be a function and ```data``` attribute must be either an array or an object. Notice also that 'test' and 'data' are reserved word and cannot be used in the names of tests just like you cannot use names of Mocha test hooks.)


Example:

```
test({
  // Attribute values is a object and neither of the exceptions applies --> describe block
  "Mu-mocha variant for nesting tests" : {
    // Again attribute values is a object and neither of the exceptions applies --> describe block
    "Boolean tests": {
      // Attribute values is a function and the for rule 1 does apply --> after block
      after: () -> {}
      // Attribute values is a function and the for rule 1 does not apply --> it block
      "Test that true is true": () => expect(true).to.be.true,
      // Attribute values is object, but exception 1 applies -> it block
      "Test that 1,2,3 are truthy": {
          data: [1,2,3];
          test: () => expect(1).to.be.ok
      }
    }
})
```
<commit_msg>Fixes issue #1, changes readme.md<commit_after># Reasoning

Mu-mocha is a wrapper around Mocha-test runner. The main design principles are:

1. **Less boilerplate**. While Mocha (and other BDD-frames) is generally less verbose
than TDD traditionally, there's still quite a lot boilerplate code that is not
necessary. Mu-mocha tries to reduce amount of boilerplate code.
2. **Context driven approach**. In the most popular test frameworks, the background
presupposition seems to be that the optimal way to unit test code is more or
lest the same in all cases. Usually, test frameworks are not easy to extend
so that testing different types of code would be as simple as possible. The most
popular frameworks also lack simple and efficient way to write data driven tests.

Mu-mocha makes data driven testing easier and allows you to write your own test builder
that makes testing of your code as simple as possible.


# Installing Mu-mocha

In order to use Mu-mocha you need to take care of two things:

1. Ensure that you can use ES6 in tests. There are many ways to take care of this.
Mu-mocha uses Babel and I instruct you to use it, but you can use another approach.
2. Install and configure Mocha. Then install Mu-mocha .
3. Ensure you have configured mocha to seek the test from correct place.

**Step 1.**  Install Babel (or enable use of ES6 in tests in another way.)

First install Babel from npm:
```
npm install babel --save-dev
```

Then run Mocha with ```--compilers js:babel/register``` switch.

You can also add this to packages.json or use any other mocha compatible build tool
like Gulp, Grunt or WebPack. Internally Mu-mocha uses npm script for tests.

```
"scripts": {
  "test": "mocha --compilers js:babel/register"
},
```

**Step 2.** Install Mocha and Mu-mocha by using npm:

```
npm install mocha --save-dev
npm install mu-mocha  --save-dev
```

**Step 3.** Ensure you have configured Mocha to seek the test from correct place.

By default Mocha seeks test from test folder. If you go with the default create
test folder for your tests.

You can also configura mocha to seek tests by file name pattern (e.g. seek files by pattern *.spec.js)

# Getting started

## Basic usage

You just need to pass and object to run Mu-mocha's ```test``` function.

```
var test = require('mu-mocha ').test,
    expect = require('chai').expect

test({
  "This is Mu-mocha descriptions": {
    "This is Mu-mocha test name":    () => expect(true).to.be.true,
    "This is inner description block": {
      "This is another Mu-mocha test": () => expect(true).to.be.true,  
    }
  }
})
```


This is same as:
```
describe("This is Mocha descriptions", function(){
  it("This is Mocha test name", function(){
    expect(true).to.be.true
  })
  describe("This is inner description block, function(){
    it("This is another Mocha test", function(){
      expect(true).to.be.true
    })
  })
})
```

## How it works

Mocha build a test tree that have two kind of nodes: describe (or context)
nodes and tests. In Mocha you build an expression tree by using describe- and
it-functions. describe and it are actually global functions that executes
that expression three you past to them as parameters.

In in Mu-mocha you use have this information in an object graph. Minimal
mocha converts an object graph into Mocha's function and then and Mocha test
runner takes care of everything else.

In practice Mu-mocha's ```test```-function loops through the all object's
attributes recursively, and converts them into mocha function calls.

There are two main rules:

1. Attributes have a function as are actual tests, what will be converted into
it-function calls. With one exception:
  1. If attribute name is after, afterEach, before, or beforeEach it will be
  converted into the corresponding Mocha test hook functions. I.e. if you need to have
  tests which name is 'after', 'afterEach', 'before' or 'beforeEach', don't use
  Minimal  Mocha - write them with Mocha instead.
2. Attributes that have an object as its value are description nodes. There is an exception to this rule:
  1. if object have both 1) ```data``` and 2) ```test``` attributes, it will be converted into a test. (Notice: ```test``` attribute must be a function and ```data``` attribute must be either an array or an object. Notice also that 'test' and 'data' are reserved word and cannot be used in the names of tests just like you cannot use names of Mocha test hooks.)


Example:

```
test({
  // Attribute values is a object and neither of the exceptions applies --> describe block
  "Mu-mocha variant for nesting tests" : {
    // Again attribute values is a object and neither of the exceptions applies --> describe block
    "Boolean tests": {
      // Attribute values is a function and the for rule 1 does apply --> after block
      after: () -> {}
      // Attribute values is a function and the for rule 1 does not apply --> it block
      "Test that true is true": () => expect(true).to.be.true,
      // Attribute values is object, but exception 1 applies -> it block
      "Test that 1,2,3 are truthy": {
          data: [1,2,3],
          test: () => expect(1).to.be.ok
      }
    }
})
```

{'fraction_non_alphanumeric': 0.08764284330815418, 'fraction_numerical': 0.005132674801472012, 'mean_word_length': 3.5333625987708515, 'pattern_counts': {'":': 18, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5118153', 'n_tokens_mistral': 2991, 'n_tokens_neox': 2804, 'n_words': 1526}