Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add peer dependency to User Event docs" #1329

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
docs: don't install @testing-library/dom
nickserv committed Oct 28, 2023
commit 0c9a7861c304293bc5200132bcf4b9d9dfcd1c24
27 changes: 16 additions & 11 deletions docs/ecosystem-user-event.mdx
Original file line number Diff line number Diff line change
@@ -25,14 +25,14 @@ fixes and new features.
<TabItem value="npm">

```sh
npm install --save-dev @testing-library/user-event @testing-library/dom
npm install --save-dev @testing-library/user-event
```

</TabItem>
<TabItem value="yarn">

```sh
yarn add --dev @testing-library/user-event @testing-library/dom
yarn add --dev @testing-library/user-event
```

</TabItem>
@@ -615,22 +615,27 @@ method.
Usage example:

```jsx
import React, { useState } from 'react'
import React, {useState} from 'react'
import {render, screen} from '@testing-library/react'
import userEvent, {specialChars} from '@testing-library/user-event'

const InputElement = () => {
const [currentValue, setCurrentValue] = useState('This is a bad example');
return <div>
<label htmlFor='my-input'>Example:</label>
<input id='my-input' type='text' value={currentValue} onChange={(e) => setCurrentValue(e.target.value)} />
</div>;
const [currentValue, setCurrentValue] = useState('This is a bad example')
return (
<div>
<label htmlFor="my-input">Example:</label>
<input
id="my-input"
type="text"
value={currentValue}
onChange={e => setCurrentValue(e.target.value)}
/>
</div>
)
}

test('delete characters within the selectedRange', () => {
render(
<InputElement/>,
)
render(<InputElement />)
const input = screen.getByLabelText(/example/i)
input.setSelectionRange(10, 13)
userEvent.type(input, `${specialChars.backspace}good`)