Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/ahrefs/melange-fest

A minimal test framework for Melange using Node test runner
https://github.com/ahrefs/melange-fest

Last synced: 7 days ago
JSON representation

A minimal test framework for Melange using Node test runner

Lists

README

        

# melange-fest

A minimal test framework for Melange using [Node test
runner](https://nodejs.org/api/test.html).

## Quick Start

```reason
open Fest

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

### React

React support is provided by
[`reason-react`](https://github.com/reasonml/reason-react/).

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

Domloader.init();

module Hello = {
[@react.component]
let make = (~text) =>

{"Hello " ++ text |> React.string}
;
};

let () =
test("test component", () => {
let result = RTL.render();

// 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:

```bash
make test
```