3purescript-spec-mocha is a runner and reporter for
4[purescript-spec](https://github.com/owickstrom/purescript-spec) that run tests
5and reports the results using the Mocha interface (`describe`, `it` etc). This
6enables you to use purescript-spec together with `mocha` and `karma`, and thus
7run tests in web browsers, as well as NodeJS.
12bower install purescript-spec-mocha
19import Control.Monad.Eff (Eff)
20import Test.Spec (SpecEffects, describe, it)
21import Test.Spec.Assertions (shouldEqual)
22import Test.Spec.Mocha (MOCHA, runMocha)
24main :: Eff (SpecEffects (mocha :: MOCHA)) Unit
26 describe "your feature" do
28 (1 + 1) `shouldEqual` 2
31### Usage with bundled Purescript
32If you bundle your compiled PureScript it can be run with `mocha bundle.js` or
33using Karma and [karma-mocha](https://github.com/karma-runner/karma-mocha).
36pulp browserify -I test --main Test.Main > bundle.js
40### Usage in the browser
41If you want to mix in Purescript tests with existing Javascript (or
42Coffeescript) Mocha tests running in the browser, you'll need to import the file
43and call the function exported by your Purescript test. E.g. combining the
44example from [Running Mocha in the
45Browser](https://mochajs.org/#running-mocha-in-the-browser) with the above
46Purscript spec, you'll need:
49<!-- test/index.html -->
51 <script>mocha.setup('bdd')</script>
52 <script src="all_tests.js"></script>
55 mocha.globals(['jQuery']);
63require('test.array.js'); // Javascript specs load when the the file is parsed.
64require('test.object.js');
65require('test.xhr.js');
67{main} = require('my_purescript_spec');
68main(); // Purescript specs load when the function is called.
71### Usage with Spago and Parcel
73With `spago` and `parcel-bundler`, and the above `test/index.html` you can build tests, and run them on node and browsers with the following entries in your `package.json`
77 "test:build": "spago bundle-app --main Test.Main --to ./output/test.js",
78 "test:watch": "spago bundle-app --watch --main Test.Main --to ./output/test.js --then \"npm run -s test:node\"",
79 "test:node": "mocha ./output/test.js",
80 "test:browser": "parcel test/index.html --open"
85Running `npm run test:watch` in one terminal window and `npm run test:browser` in another will watch purescript source and tests files and automatically run node and browser tests.
89See [docs on Pursuit](https://pursuit.purescript.org/packages/purescript-spec-mocha).
93If you have any issues or possible improvements please file them as
94[GitHub Issues](https://github.com/owickstrom/purescript-spec-mocha/issues).
95Pull requests requests are encouraged.
99This project's tests include some failures to test the Mocha
100integration. Thus, use `run_tests.sh` instead of `pulp test` to check
101that everything is all right.
105[MIT License](LICENSE.md).
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list