Skip to content

Commit 3feba77

Browse files
authored
doc: Updating readme with correct query names
Updating readme
2 parents bf35298 + 11f6e9c commit 3feba77

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This library compliments `@testing-library/react` to make it easy to setup and m
2222

2323
1. First, import this library and the component you are mocking in your test:
2424
```Typescript
25-
import {setupMockComponent, getMockComponent} from '@sourceallies/rtl-mock-component';
25+
import {setupMockComponent, getByMockComponent} from '@sourceallies/rtl-mock-component';
2626
import MyChildComponent from './MyChildComponent';
2727
```
2828
2. Next, mock the module just like any other mock:
@@ -38,11 +38,11 @@ This library compliments `@testing-library/react` to make it easy to setup and m
3838
4. Now, when you call `render` with any ancestor component, the implementation will not be called and a stub element will be rendered in its place.
3939
5. If you want to assert the component is in the dom you can do it as so:
4040
```Typescript
41-
expect(getMockComponent(MyChildComponent)).toBeInTheDocument();
41+
expect(getByMockComponent(MyChildComponent)).toBeInTheDocument();
4242
```
4343
6. `getMockComponent` and the other query functions return a `MockedComponentElement<T>` that extends from `HTMLElement` and adds a `props` property that can be asserted on. For example, to make sure that the compnent is currently rendered with the open prop set to true:
4444
```Typescript
45-
expect(getMockComponent(MyChildComponent).props.open).toBe(true);
45+
expect(getByMockComponent(MyChildComponent).props.open).toBe(true);
4646
```
4747

4848
*Note:* this way of testing ensures that the component is **currently** rendered with the provided value. Jest's `toHaveBeenCalledWith` would only test that was ever rendered with the expected value.

0 commit comments

Comments
 (0)