BuckleScript bindings for dom-testing-library.
Switch branches/tags
Clone or download
Latest commit 4c5d839 Oct 10, 2018

readme.md

bs-dom-testing-library

Build Status npm

BuckleScript bindings for dom-testing-library.

Installation

$ yarn add --dev bs-dom-testing-library

# or..

$ npm install --save-dev bs-dom-testing-library

Usage

Add to bsconfig.json

{
  "bs-dev-dependencies": [
    "bs-dom-testing-library"
  ]
}

With bs-jest

/* A_test.re */

open Jest;

[@bs.new]
external domParser : unit => parser = "DOMParser";

[@bs.send.pipe : parser]
external parseFromString : ( string, [@bs.as "text/html"] _) => Dom.element = "";

[@bs.get]
external body : Dom.element => Dom.element = "";

[@bs.get]
external firstChild : Dom.element => Dom.element = "";

describe("prettyDOM", () => {
  open Expect;

  let div = domParser()
    |> parseFromString("<div><b>Hello,</b><p> World!</p></div>")
    |> body
    |> firstChild;

  describe("prettyDOM", () => {
    test("works", () => {
      let actual = div |> DomTestingLibrary.prettyDOM;

      expect(actual) |> toMatchSnapshot;
    });

    test("works with maxLength", () => {
      let actual = div |> DomTestingLibrary.prettyDOM(~maxLength=25);

      expect(actual) |> toMatchSnapshot;
    });
  });
});

Examples

See src/__tests__ for some examples.

Development

$ git clone https://github.com/wyze/bs-dom-testing-library.git
$ cd bs-dom-testing-library
$ yarn # or `npm install`

Build

$ yarn build

Test

$ yarn test

Change Log

Full Change Log

v0.3.0 (2018-10-10)

  • [2a6ddfe79f] - Split main module into submodules (#4) (Neil Kistner)
  • [584e1de278] - Add FireEvent.click and FireEvent.change methods (#2) (Neil Kistner)
  • [c6aa67ffcf] - Add ignore option to getByText query (#3) (Neil Kistner)
  • [8424bb3f8e] - Upgrade dependencies (Neil Kistner)

License

MIT © Neil Kistner