Skip to content

Latest commit

 

History

History
63 lines (48 loc) · 1.28 KB

ecosystem-bs-jest-dom.mdx

File metadata and controls

63 lines (48 loc) · 1.28 KB
id title
ecosystem-bs-jest-dom
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

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__.