A library to create interactive test suites for PureScript functions.
- Live demo and tutorial
- Try Flare - Write and compile FlareCheck UIs in your browser
- Talk - A talk I gave about Flare and FlareCheck at LambdaConf 2016
- Module documentation
- Flare: underlying UI library
Suppose you have written a function
substring :: Int -> Int -> String -> String
substring start end str = take (end - start) (drop start str)
that you want to test. To use FlareCheck, you simply call (the first argument is just a title for the test):
flareCheck "substring" substring
This automatically creates an interactive testing environment (see demo page for a working version) like this:
Notice how the type information is used to create appropriate input fields for Int
and String
. Similarly, calling
flareCheck "filter even" (filter even)
creates the following interface:
- The module that you want to test (
src/MyModule.purs
):
module MyModule (substring) where
import Prelude
import Data.String
substring :: Int -> Int -> String -> String
substring start end str = take (end - start) (drop start str)
- A module which runs the tests (
test/Main.purs
):
module Test.Main where
import Prelude
import MyModule
import Test.FlareCheck
main = flareCheck "substring" substring
- The compiled test module (
test.js
), run:
pulp build -O -I test -m Test.Main -t test.js
- An accompanying HTML file which includes an empty element with ID
tests
that runs the script:
<div id="tests"></div>
<script src="test.js"></script>
See the assets folder for full HTML and CSS templates.