| Copyright | (C) 2016-2025 David M. Johnson (@dmjio) |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.Test
Contents
Description
An hspec-like miso testing framework. Meant for testing miso Component.
The testing framework operates in the jsaddle JSM monad and has access
to the DOM courtesy of JSDOM and Playwright.
main :: IO ()
main = runTests $ do
describe "Arithmetic tests" $ do
it "2 + 2 = 4" $ do
(2 + 2) `shouldBe` 4
Synopsis
- describe :: MisoString -> Test () -> Test ()
- it :: MisoString -> Test () -> Test ()
- expect :: (Eq a, Show a) => (a -> a -> Bool) -> a -> a -> Test ()
- beforeEach :: JSM () -> Test () -> Test ()
- afterEach :: JSM () -> Test () -> Test ()
- shouldBe :: (Show a, Eq a) => a -> a -> Test ()
- shouldNotBe :: (Show a, Eq a) => a -> a -> Test ()
- runTests :: Test a -> IO ()
- jsm :: JSM a -> Test a
- choose :: Int -> Int -> JSM Int
- type Test a = StateT TestState JSM a
- data TestState
Test Combinators
Arguments
| :: MisoString | Description of test group |
| -> Test () | Group of tests to run |
| -> Test () |
Used to group a bunch of expectations using it. Testing out
will include the test description in its output.
Arguments
| :: MisoString | Name of test to execute |
| -> Test () | Test holding multiple expectations |
| -> Test () |
Used to make multiple expectations using shouldBe / shouldNotBe.
expect :: (Eq a, Show a) => (a -> a -> Bool) -> a -> a -> Test () Source #
Primitive for performing expectations in an it block.
Utils
Return a random integer between the first two provided [min, max)
The maximum is exclusive and the minimum is inclusive