You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+105-6Lines changed: 105 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -66,6 +66,7 @@ clear to read and to maintain.
66
66
-[`toHaveStyle`](#tohavestyle)
67
67
-[`toHaveTextContent`](#tohavetextcontent)
68
68
-[`toHaveValue`](#tohavevalue)
69
+
-[`toBeChecked`](#tobechecked)
69
70
-[Deprecated matchers](#deprecated-matchers)
70
71
-[`toBeInTheDOM`](#tobeinthedom)
71
72
-[Inspiration](#inspiration)
@@ -97,7 +98,8 @@ Import `@testing-library/jest-dom/extend-expect` once (for instance in your
97
98
import'@testing-library/jest-dom/extend-expect'
98
99
```
99
100
100
-
> Note: If you're using TypeScript, make sure your setup file is a `.ts` and not a `.js` to include the necessary types.
101
+
> Note: If you're using TypeScript, make sure your setup file is a `.ts` and not
102
+
> a `.js` to include the necessary types.
101
103
102
104
Alternatively, you can selectively import only the matchers you intend to use,
103
105
and extend jest's `expect` yourself:
@@ -108,7 +110,9 @@ import {toBeInTheDocument, toHaveClass} from '@testing-library/jest-dom'
108
110
expect.extend({toBeInTheDocument, toHaveClass})
109
111
```
110
112
111
-
> Note: when using TypeScript, this way of importing matchers won't provide the necessary type definitions. More on this [here](https://github.com/testing-library/jest-dom/pull/11#issuecomment-387817459).
113
+
> Note: when using TypeScript, this way of importing matchers won't provide the
'only inputs with type="checkbox" or type="radio" or elements with role="checkbox" or role="radio" and a valid aria-checked attribute can be used with .toBeChecked(). Use .toHaveValue() instead',
133
+
)
134
+
})
135
+
136
+
test('throws when element with role="radio" has an invalid aria-checked attribute',()=>{
'only inputs with type="checkbox" or type="radio" or elements with role="checkbox" or role="radio" and a valid aria-checked attribute can be used with .toBeChecked(). Use .toHaveValue() instead',
145
+
)
146
+
})
147
+
148
+
test('throws when the element is not an input',()=>{
'only inputs with type="checkbox" or type="radio" or elements with role="checkbox" or role="radio" and a valid aria-checked attribute can be used with .toBeChecked(). Use .toHaveValue() instead',
'only inputs with type="checkbox" or type="radio" or elements with role="checkbox" or role="radio" and a valid aria-checked attribute can be used with .toBeChecked(). Use .toHaveValue() instead',
0 commit comments