A test runner and reporter for purescript-spec that integrates with Mocha
Go to file
2019-09-05 07:15:03 +02:00
src/Test/Spec update to work with spec v4 2019-09-05 07:15:03 +02:00
test Update spec-mocha for purescript 0.12 2018-06-23 22:16:38 +08:00
.gitignore Initial commit 2015-07-27 19:47:01 +02:00
.travis.yml Bump CI purescript version 2019-09-05 07:10:02 +02:00
bower.json update to work with spec v4 2019-09-05 07:15:03 +02:00
karma.conf.js Adapt to purescript-spec-0.11.0 2017-01-12 07:38:51 +01:00
LICENSE Initial commit 2015-07-27 19:47:01 +02:00
README.md Add to README how one might combine purescript-spec-mocha with existing browser JS tests 2018-03-08 09:40:47 -08:00
run_tests.sh Add test runner script with proper checking 2017-10-04 08:14:49 +02:00

purescript-spec-mocha

purescript-spec-mocha is a runner and reporter for purescript-spec that run tests and reports the results using the Mocha interface (describe, it etc). This enables you to use purescript-spec together with mocha and karma, and thus run tests in web browsers, as well as NodeJS.

Usage

bower install purescript-spec-mocha
module Main where

import Prelude
import Control.Monad.Eff (Eff)
import Test.Spec (SpecEffects, describe, it)
import Test.Spec.Assertions (shouldEqual)
import Test.Spec.Mocha (MOCHA, runMocha)

main :: Eff (SpecEffects (mocha :: MOCHA)) Unit
main = runMocha do
  describe "your feature" do
    it "works" $
      (1 + 1) `shouldEqual` 2

Usage with bundled Purescript

If you bundle your compiled PureScript it can be run with mocha bundle.js or using Karma and karma-mocha.

pulp browserify -I test --main Test.Main > bundle.js
mocha bundle.js

Usage in the browser

If you want to mix in Purescript tests with existing Javascript (or Coffeescript) Mocha tests running in the browser, you'll need to import the file and call the function exported by your Purescript test. E.g. combining the example from Running Mocha in the Browser with the above Purscript spec, you'll need:

<!-- test/index.html -->
...
  <script>mocha.setup('bdd')</script>
  <script src="all_tests.js"></script>
  <script>
    mocha.checkLeaks();
    mocha.globals(['jQuery']);
    mocha.run();
  </script>
...
// all_tests.js
require('test.array.js');               // Javascript specs load when the the file is parsed.
require('test.object.js');
require('test.xhr.js');

{main} = require('my_purescript_spec');
main();                                 // Purescript specs load when the function is called.

API Documentation

See docs on Pursuit.

Contribute

If you have any issues or possible improvements please file them as GitHub Issues. Pull requests requests are encouraged.

Running Tests

This project's tests include some failures to test the Mocha integration. Thus, use run_tests.sh instead of pulp test to check that everything is all right.

License

MIT License.