Skip to content

Commit 4d88ef5

Browse files
committed
docs: add README
1 parent 2dbc33b commit 4d88ef5

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# ReScript React Testing Library
2+
3+
[![npm](https://img.shields.io/npm/v/rescript-react-testing-library?label=version&style=flat-square)](https://www.npmjs.com/package/rescript-react-testing-library)
4+
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/brnrdog/rescript-react-testing-library/Version%20Release?style=flat-square)](https://github.com/brnrdog/rescript-react-testing-library/actions/workflows/release.yml)
5+
![Codecov](https://img.shields.io/codecov/c/github/brnrdog/rescript-react-testing-library?style=flat-square)
6+
7+
ReScript bindings for [testing-library/react](https://github.com/testing-library/react-testing-library/).
8+
9+
## Install
10+
11+
```bash
12+
npm install --save-dev rescript-react-testing-library
13+
# or yarn
14+
yarn add --dev rescript-react-testing-library
15+
```
16+
17+
Update your bsconfig file:
18+
19+
```json
20+
{
21+
"bs-dev-dependencies": ["rescript-react-testing-library"]
22+
}
23+
```
24+
25+
## Usage
26+
27+
```res
28+
open Jest
29+
open Expect
30+
open ReactTestingLibrary
31+
32+
module Dummy = {
33+
@react.component
34+
let make = () => {
35+
<div>
36+
<label> {React.string("Choose a color")} </label>
37+
<select>
38+
<option> {React.string("Red")} </option>
39+
<option> {React.string("Green")} </option>
40+
<option> {React.string("Blue")} </option>
41+
</select>
42+
</div>
43+
}
44+
}
45+
46+
let setup = () => {
47+
renderElement(<Dummy />)
48+
}
49+
50+
test("render red option", () => {
51+
setup()->getByRole(~matcher=#Str("option"), ~options=makeByRoleOptions(~name="Red", ()))
52+
|> expect
53+
|> toMatchSnapshot
54+
})
55+
56+
test("render red option", () => {
57+
setup()->getByRole(~matcher=#Str("option"), ~options=makeByRoleOptions(~name="Green", ()))
58+
|> expect
59+
|> toMatchSnapshot
60+
})
61+
62+
test("render red option", () => {
63+
setup()->getByRole(~matcher=#Str("option"), ~options=makeByRoleOptions(~name="Blue", ()))
64+
|> expect
65+
|> toMatchSnapshot
66+
})
67+
```

0 commit comments

Comments
 (0)