Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@greenlabs/rescript-testing-library) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
rescript-testing-library
Install
npm i @greenlabs/rescript-testing-library --dev
or
yarn add @greenlabs/rescript-testing-library --dev"bs-dev-dependencies": [
"@greenlabs/rescript-testing-library"
]Usage
module TestComponent = {
@react.component
let make = () => {
let (show, setShow) = React.useState(_ => false)
<div>
<button type_="button" onClick={_ => setShow(prev => !prev)}>
{`Toggle`->React.string}
</button>
{show ? <h1 title="my_title"> {`Hello World`->React.string} </h1> : React.null}
</div>
}
}
open! Jest
open! Expect
open! TestingLibrary.JestExpect
open! TestingLibrary.Dom
open! TestingLibrary.Dom.Queries
module Event = TestingLibrary.Event
testAsync("uses jest-dom", done => {
let userEvent = Event.setup()
TestingLibrary.React.render(<TestComponent />)->ignore
expect(screen->ByTitle.find("my_title"))->not->toBeInTheDocument
userEvent->Event.click(screen->ByText.get("Toggle"))
->Promise.thenResolve(_ => {
expect(screen->ByTitle.find("my_title"))->toBeInTheDocument
done()
})
->ignore
})