From f2d1338a66a564b4557fa801815420f9ddbc31fc Mon Sep 17 00:00:00 2001 From: Winston Date: Thu, 8 Mar 2018 09:40:47 -0800 Subject: [PATCH] Add to README how one might combine purescript-spec-mocha with existing browser JS tests --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index 3a127c1..f4c9aae 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ main = runMocha do (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](https://github.com/karma-runner/karma-mocha). @@ -36,6 +37,37 @@ 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](https://mochajs.org/#running-mocha-in-the-browser) with the above +Purscript spec, you'll need: + +```html + +... + + + +... +``` + +```javascript +// 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](https://pursuit.purescript.org/packages/purescript-spec-mocha).