package melange-fest

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

Install

Dune Dependency

Authors

Maintainers

Sources

melange-fest-0.1.0.tbz
sha256=34f8c000dfee70dda1838c600584e6b6f67f7de1a230b2a46d1bc024c50e1afb
sha512=63d29ab4434a4c3de24ff8c86fd01c114f3a9b068e568f7848b2ff63086bc0a6526493e21c18e4d12067e7f8fa85872de514d828a30d2ce49cfc5a5acbc6014d

Description

A minimal test framework for Melange using Node test runner

Tags

melange node org:ahrefs

Published: 08 Mar 2024

README

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

Dependencies (3)

  1. melange >= "3.0"
  2. dune >= "3.9"
  3. ocaml

Dev Dependencies (7)

  1. ocamlformat with-test
  2. odoc with-doc
  3. ocaml-lsp-server with-test
  4. melange-testing-library with-test
  5. reason-react-ppx with-test
  6. reason-react with-test
  7. reason with-test

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.