Skip to main content

bs-jest-dom

bs-jest-dom is a companion library for bs-react-testing-library that provides custom DOM element matchers for Jest in ReasonML via BuckleScript.

npm install --save-dev bs-jest-dom

Check out jest-dom's documentation for a full list of available matchers.

Setup

{
"bs-dev-dependencies": ["bs-jest-dom"]
}

Example

A_test.re
open Jest;
open JestDom;
open ReactTestingLibrary;

module Heading = {
let component = ReasonReact.statelessComponent("Heading");

let make = (~text, _children) => {
...component,
render: _self =>
<h1> {ReasonReact.string(text)} </h1>,
};
};

test("renders with text", () =>
<Heading text="Hello, World!" />
|> render
|> getByText(~matcher=`Str("Hello, World!"))
|> expect
|> toBeInTheDocument
);

More Examples

You can find more bs-jest-dom examples at wyze/bs-jest-dom/src/__tests__.