From 0c9a7861c304293bc5200132bcf4b9d9dfcd1c24 Mon Sep 17 00:00:00 2001 From: Nick McCurdy <nick@nickmccurdy.com> Date: Sat, 28 Oct 2023 15:22:33 -0400 Subject: [PATCH 1/4] docs: don't install `@testing-library/dom` --- docs/ecosystem-user-event.mdx | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/docs/ecosystem-user-event.mdx b/docs/ecosystem-user-event.mdx index c715a584a..3507d4d40 100644 --- a/docs/ecosystem-user-event.mdx +++ b/docs/ecosystem-user-event.mdx @@ -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`) From 741cabdc6f49e684683a7dfffde3f7ea8f441c62 Mon Sep 17 00:00:00 2001 From: Nick McCurdy <nick@nickmccurdy.com> Date: Tue, 31 Oct 2023 00:03:31 -0400 Subject: [PATCH 2/4] docs: remove note on peer deps to reduce confusion --- docs/user-event/install.mdx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/docs/user-event/install.mdx b/docs/user-event/install.mdx index db2be35f6..c2f1f8e32 100644 --- a/docs/user-event/install.mdx +++ b/docs/user-event/install.mdx @@ -25,12 +25,3 @@ yarn add --dev @testing-library/user-event </TabItem> </Tabs> - -Note that `@testing-library/user-event` requires `@testing-library/dom`. - -If you use one of the -[framework wrappers](../dom-testing-library/install.mdx#wrappers), it is -important that `@testing-library/dom` is resolved to the same installation -required by the framework wrapper of your choice. -Usually this means that if you use one of the framework wrappers, you should not -add `@testing-library/dom` to your project dependencies. From 0ced89c8bc709cca6661a7b26eec738247246b29 Mon Sep 17 00:00:00 2001 From: Nick McCurdy <nick@nickmccurdy.com> Date: Thu, 2 Nov 2023 16:50:44 -0400 Subject: [PATCH 3/4] docs: don't install @testing-library/dom --- docs/react-testing-library/migrate-from-enzyme.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/react-testing-library/migrate-from-enzyme.mdx b/docs/react-testing-library/migrate-from-enzyme.mdx index cf04d9298..bdb74fe56 100644 --- a/docs/react-testing-library/migrate-from-enzyme.mdx +++ b/docs/react-testing-library/migrate-from-enzyme.mdx @@ -297,7 +297,7 @@ resemble the way your software is actually used. To use the `@testing-library/user-event` module, first install it: ```bash npm2yarn -npm install --save-dev @testing-library/user-event @testing-library/dom +npm install --save-dev @testing-library/user-event ``` Now you can import it into your test: From e2dabe57eb016e586cdc616901eb0dc01d7cf6a2 Mon Sep 17 00:00:00 2001 From: Nick McCurdy <nick@nickmccurdy.com> Date: Thu, 9 Nov 2023 19:53:33 -0500 Subject: [PATCH 4/4] Revert "docs: remove note on peer deps to reduce confusion" This reverts commit 741cabdc6f49e684683a7dfffde3f7ea8f441c62. --- docs/user-event/install.mdx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/user-event/install.mdx b/docs/user-event/install.mdx index c2f1f8e32..db2be35f6 100644 --- a/docs/user-event/install.mdx +++ b/docs/user-event/install.mdx @@ -25,3 +25,12 @@ yarn add --dev @testing-library/user-event </TabItem> </Tabs> + +Note that `@testing-library/user-event` requires `@testing-library/dom`. + +If you use one of the +[framework wrappers](../dom-testing-library/install.mdx#wrappers), it is +important that `@testing-library/dom` is resolved to the same installation +required by the framework wrapper of your choice. +Usually this means that if you use one of the framework wrappers, you should not +add `@testing-library/dom` to your project dependencies.