<commit_before># purescript-spec

purescript-spec is a simple testing framework for Purescript using NodeJS. It's
inspired by [hspec](http://hspec.github.io/).

<img src="https://raw.githubusercontent.com/owickstrom/purescript-spec/master/example.png" width="400" />

## Usage

```bash
bower install purescript-spec
```

### Example

The specs shown in the image above:

```purescript
module Main where

import Prelude

import Control.Monad.Aff
import Test.Spec                  (describe, pending, it)
import Test.Spec.Runner           (run)
import Test.Spec.Assertions       (shouldEqual)
import Test.Spec.Reporter.Console (consoleReporter)

main = run [consoleReporter] do
  describe "purescript-spec" do
    describe "What is it?" do
      it "awesome" do
        let isAwesome = true
        isAwesome `shouldEqual` true
    describe "Features" do
      it "runs in NodeJS" $ return unit
      it "runs in the browser" $ return unit
      it "supports async specs" do
        res <- later' 100 $ return "Alligator"
        res `shouldEqual` "Alligator"
      it "is PureScript 0.7 compatible" $ return unit
```

### Embedding Specs

In the example `additionSpec` is embedded into the `Math` specification. This
is useful if you want to split specifications into multiple files and combine
them in `Main`.

```purescript
main = runNode [consoleReporter] do
  mathSpec
  stringsSpec
  arraySpec
  ...
```

### Reporters

Reporters can be passed to the runner, e.g. `runNode [reporter1, ..., reporterN]
spec`. Currently there are these reporters available:

* [`Test.Spec.Reporter.Console.consoleReporter`](docs/Test/Spec/Reporter/Console.md#consolereporter)
* [purescript-spec-reporter-xunit](https://github.com/owickstrom/purescript-spec-reporter-xunit)

### Async

Specs can be async as the test body type of `it` is
[forall e. Aff e Unit](https://github.com/slamdata/purescript-aff)

### Running Tests

When using `runNode` you can follow the conventions of
[pulp](https://github.com/bodil/pulp) and run your tests with `pulp test`.

If you're not using pulp you can compile using `psc` and run the compiled
Javascript with `node`.

```bash
# compile with psc (modify the command to include all your sources)
psc -o output/tests 'test/**/*.purs' 'src/**/*.purs' --ffi 'src/**/*.js'<commit_msg>Add mocha reporter to list<commit_after># purescript-spec

purescript-spec is a simple testing framework for Purescript using NodeJS. It's
inspired by [hspec](http://hspec.github.io/).

<img src="https://raw.githubusercontent.com/owickstrom/purescript-spec/master/example.png" width="400" />

## Usage

```bash
bower install purescript-spec
```

### Example

The specs shown in the image above:

```purescript
module Main where

import Prelude

import Control.Monad.Aff
import Test.Spec                  (describe, pending, it)
import Test.Spec.Runner           (run)
import Test.Spec.Assertions       (shouldEqual)
import Test.Spec.Reporter.Console (consoleReporter)

main = run [consoleReporter] do
  describe "purescript-spec" do
    describe "What is it?" do
      it "awesome" do
        let isAwesome = true
        isAwesome `shouldEqual` true
    describe "Features" do
      it "runs in NodeJS" $ return unit
      it "runs in the browser" $ return unit
      it "supports async specs" do
        res <- later' 100 $ return "Alligator"
        res `shouldEqual` "Alligator"
      it "is PureScript 0.7 compatible" $ return unit
```

### Embedding Specs

In the example `additionSpec` is embedded into the `Math` specification. This
is useful if you want to split specifications into multiple files and combine
them in `Main`.

```purescript
main = runNode [consoleReporter] do
  mathSpec
  stringsSpec
  arraySpec
  ...
```

### Reporters

Reporters can be passed to the runner, e.g. `run [reporter1, ..., reporterN]
spec`. Currently there are these reporters available:

* [`Test.Spec.Reporter.Console.consoleReporter`](docs/Test/Spec/Reporter/Console.md#consolereporter)
* [purescript-spec-reporter-xunit](https://github.com/owickstrom/purescript-spec-reporter-xunit)
* [purescript-spec-reporter-mocha](https://github.com/owickstrom/purescript-spec-reporter-mocha)

### Async

Specs can be async as the test body type of `it` is
[forall e. Aff e Unit](https://github.com/slamdata/purescript-aff)

### Running Tests

When using `runNode` you can follow the conventions of
[pulp](https://github.com/bodil/pulp) and run your tests with `pulp test`.

If you're not using pulp you can compile using `psc` and run the compiled
Javascript with `node`.

```bash
# compile with psc (modify the command to include all your sources)
psc -o output/tests 'test/**/*.purs' 'src/**/*.purs' --ffi 'src/**/*.js'
{'fraction_non_alphanumeric': 0.11628401360544217, 'fraction_numerical': 0.003826530612244898, 'mean_word_length': 3.705, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 9, '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': '6355101', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1461, 'n_words': 488}