@drewschrauf/bs-react-hooks-testing-library
v0.1.1
Published
[@testing-library/react-hooks-testing-library](https://github.com/testing-library/react-hooks-testing-library) Reason/BuckleScript bindings.
Downloads
2
Maintainers
Readme
@drewschrauf/bs-react-hooks-testing-library
@testing-library/react-hooks-testing-library Reason/BuckleScript bindings.
Installation
Install as a dev dependency:
npm install --save-dev @drewschrauf/bs-react-hooks-testing-library
Add it to your bsconfig.json as a dev dependency.
{
...
"bs-dev-dependencies": [
...
"@drewschrauf/bs-react-hooks-testing-library"
]
}
It's recommended to add open ReactHooksTestingLibrary
at the top of each test file.
API
This documentation covers the specifics of these bindings. To learn about the principles and approach behind Testing Library, refer to the official documentation.
All methods from @testing-library/react-hooks-testing-library are implemented. Values that are returned from renderHook
in the original JavaScript version have getter methods equivalents in there bindings. For example, the JavaScript method to retrieve a hooks current value is:
const { result } = renderHook(() => React.useState(1));
console.log(result.current) // logs "1"
The equalivent in these bindings is the current
method:
const result = renderHook(() => React.useState(_ => 1));
Js.log(result |> current) // logs "1"
Review the interface file for the full API. Example tests are also available.