package melange-fest

  1. Overview
  2. Docs
A minimal test framework for Melange

Install

dune-project
 Dependency

Authors

Maintainers

Sources

melange-fest-0.2.0.tbz
sha256=9f578ecb9bc185a5bab983b59ac08aa079bd41058f19d3e902d94fdf552f9c88
sha512=2b59e1e23d4c027df99ebd94eeb9c49d0b5a024f22ebfd01ff19ea9497348c60adaf67f161aaac743ae94d8093240399463a0eb0dffce8351fa75a73d99a9c88

doc/README.html

melange-fest

A minimal test framework for Melange using Node test runner.

Quick Start

open Fest

test("1+1=2", () => expect |> equal(1 + 1, 2));

React

React support is provided by reason-react.

open Fest;
module RTL = ReactTestingLibrary;
[@mel.get] external textContent: Dom.element => string = "textContent";

Domloader.init();

module Hello = {
  [@react.component]
  let make = (~text) => <div> {"Hello " ++ text |> React.string} </div>;
};

let () =
  test("test component", () => {
    let result = RTL.render(<Hello text="Nila" />);

    // Check that Hello component renders the name properly.
    let el = RTL.getByText(~matcher=`Str("Hello Nila"), result);
    expect |> equal(textContent(el), "Hello Nila");
  });

Commands

Run all tests:

make test