purescript-spec-mocha is a runner and reporter for
purescript-spec that run tests
and reports the results using the Mocha interface (
it etc). This
enables you to use purescript-spec together with
karma, and thus
run tests in web browsers, as well as NodeJS.
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
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
<!-- test/index.html --> ... <script>mocha.setup('bdd')</script> <script src="all_tests.js"></script> <script> mocha.checkLeaks(); mocha.globals(['jQuery']); mocha.run(); </script> ...
See docs on Pursuit.
If you have any issues or possible improvements please file them as GitHub Issues. Pull requests requests are encouraged.
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.