A list of jest-dom bindings for Rescript
# using npm
npm install @endosama/rescript-jest-dom
# using yarn
yarn add @endosama/rescript-jest-domand then add the package as a dependency in your bsconfig.json file:
"bs-dependencies": [
...,
"@endosama/rescript-jest-dom"
]open Jest
open Expect
open JestDom
element->expect->toHaveTextContent(#Str("Hello there!")) // passAutomatically generated using chat-gpt. If anything is missing check the jest-dom Documentation
Asserts that the specified element is in the document.
expect(dom)->ExpectDom.toBeInTheDocument()
Asserts that the specified element has the given class.
expect(dom)->ExpectDom.toHaveClass(className)
className: The class to check for.
Asserts that the specified element has the given attribute.
expect(dom)->ExpectDom.toHaveAttribute(attributeName, attributeValue?)
attributeName: The attribute to check for.attributeValue(optional): The expected value of the attribute. If not provided, only the presence of the attribute is checked.
Asserts that the specified element has the given text content.
expect(dom)->ExpectDom.toHaveTextContent(text)
text: The text content to check for.
Asserts that the specified element has the given value.
expect(dom)->ExpectDom.toHaveValue(value)
value: The value to check for.
Asserts that the specified input element (of type checkbox or radio) is checked or not.
expect(dom)->ExpectDom.toBeChecked