ReScript bindings for @testing-library/dom
npm install rescript-dom-testing-library

!Codecov
ReScript bindings for testing-library/dom.
``bash`
npm install --save-dev rescript-dom-testing-libraryor yarn
yarn add --dev rescript-dom-testing-library
Update your bsconfig file:
`json`
{
"bs-dev-dependencies": ["rescript-dom-testing-library"]
}
`res
open Jest
open JestDom
open DomTestingLibrary
let render = %raw(
function(html) {
const body = document.querySelector('body')
body.innerHTML = html
return body
})
let example = render()
test("renders label", () => {
example
->getByLabelText(~matcher=#RegExp(Js.Re.fromString("select a color")))
->expect
->toBeInTheDocument
})
test("renders red option (using string)", () => {
let options = makeByRoleOptions(~name="Red", ())
example
->getByRole(~matcher=#Str("option"), ~options)
->expect
->toBeInTheDocument
})
test("renders red option (using regular expression)", () => {
let options = makeByRoleOptionsWithRegex(
~name=Js.Re.fromStringWithFlags("/green/", ~flags="i"),
(),
)
example
->getByRole(~matcher=#Str("option"), ~options)
->expect
->toBeInTheDocument
})
test("renders blue option (using custom function)", () => {
let options = makeByRoleOptionsWithFunction(~name=(content, _element) => content === "Blue", ())
example
->getByRole(~matcher=#Str("option"), ~options)
->expect
->toBeInTheDocument
})
``
See the tests for more examples.