Skip to content

Commit 0db8112

Browse files
chore: update React imports (#811)
1 parent c2806fc commit 0db8112

14 files changed

+23
-25
lines changed

README.md

+10-12
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ afterAll(() => {
154154

155155
```jsx
156156
// hidden-message.js
157-
import React from 'react'
157+
import * as React from 'react'
158158

159159
// NOTE: React Testing Library works well with React Hooks and classes.
160160
// Your tests will be the same regardless of how you write your components.
@@ -184,7 +184,7 @@ export default HiddenMessage
184184
import '@testing-library/jest-dom'
185185
// NOTE: jest-dom adds handy assertions to Jest and is recommended, but not required
186186

187-
import React from 'react'
187+
import * as React from 'react'
188188
import {render, fireEvent, screen} from '@testing-library/react'
189189
import HiddenMessage from '../hidden-message'
190190

@@ -209,7 +209,7 @@ test('shows the children when the checkbox is checked', () => {
209209

210210
```jsx
211211
// login.js
212-
import React from 'react'
212+
import * as React from 'react'
213213

214214
function Login() {
215215
const [state, setState] = React.useReducer((s, a) => ({...s, ...a}), {
@@ -233,9 +233,7 @@ function Login() {
233233
password: passwordInput.value,
234234
}),
235235
})
236-
.then((r) =>
237-
r.json().then((data) => (r.ok ? data : Promise.reject(data)))
238-
)
236+
.then(r => r.json().then(data => (r.ok ? data : Promise.reject(data))))
239237
.then(
240238
user => {
241239
setState({loading: false, resolved: true, error: null})
@@ -276,15 +274,15 @@ export default Login
276274
// again, these first two imports are something you'd normally handle in
277275
// your testing framework configuration rather than importing them in every file.
278276
import '@testing-library/jest-dom'
279-
import React from 'react'
277+
import * as React from 'react'
280278
// import API mocking utilities from Mock Service Worker.
281279
import {rest} from 'msw'
282280
import {setupServer} from 'msw/node'
283281
// import testing utilities
284282
import {render, fireEvent, screen} from '@testing-library/react'
285283
import Login from '../login'
286284

287-
const fakeUserResponse = { token: 'fake_user_token' }
285+
const fakeUserResponse = {token: 'fake_user_token'}
288286
const server = setupServer(
289287
rest.post('/api/login', (req, res, ctx) => {
290288
return res(ctx.json(fakeUserResponse))
@@ -400,8 +398,8 @@ principles:
400398
`react-dom`.
401399
3. Utility implementations and APIs should be simple and flexible.
402400
403-
Most importantly, we want React Testing Library to be pretty
404-
light-weight, simple, and easy to understand.
401+
Most importantly, we want React Testing Library to be pretty light-weight,
402+
simple, and easy to understand.
405403
406404
## Docs
407405
@@ -410,8 +408,7 @@ light-weight, simple, and easy to understand.
410408
411409
## Issues
412410
413-
Looking to contribute? Look for the [Good First Issue][good-first-issue]
414-
label.
411+
Looking to contribute? Look for the [Good First Issue][good-first-issue] label.
415412
416413
### 🐛 Bugs
417414
@@ -607,6 +604,7 @@ Thanks goes to these people ([emoji key][emojis]):
607604
608605
<!-- markdownlint-enable -->
609606
<!-- prettier-ignore-end -->
607+
610608
<!-- ALL-CONTRIBUTORS-LIST:END -->
611609
612610
This project follows the [all-contributors][all-contributors] specification.

src/__tests__/act.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import * as React from 'react'
22
import {render, fireEvent, screen} from '../'
33

44
test('render calls useEffect immediately', () => {

src/__tests__/auto-cleanup-skip.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import * as React from 'react'
22

33
let render
44
beforeAll(() => {

src/__tests__/auto-cleanup.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import * as React from 'react'
22
import {render} from '../'
33

44
// This just verifies that by importing RTL in an

src/__tests__/cleanup.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import * as React from 'react'
22
import {render, cleanup} from '../'
33

44
test('cleans up the document', () => {

src/__tests__/debug.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import * as React from 'react'
22
import {render, screen} from '../'
33

44
beforeEach(() => {

src/__tests__/end-to-end.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import * as React from 'react'
22
import {render, waitForElementToBeRemoved, screen} from '../'
33

44
const fetchAMessage = () =>

src/__tests__/events.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import * as React from 'react'
22
import {render, fireEvent} from '../'
33

44
const eventTypes = [

src/__tests__/multi-base.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import * as React from 'react'
22
import {render} from '../'
33

44
// these are created once per test suite and reused for each case

src/__tests__/render.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import * as React from 'react'
22
import ReactDOM from 'react-dom'
33
import {render, screen} from '../'
44

src/__tests__/rerender.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import * as React from 'react'
22
import {render} from '../'
33

44
test('rerender will re-render the element', () => {

src/__tests__/stopwatch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import * as React from 'react'
22
import {render, fireEvent, screen} from '../'
33

44
class StopWatch extends React.Component {

src/act-compat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import * as React from 'react'
22
import ReactDOM from 'react-dom'
33
import * as testUtils from 'react-dom/test-utils'
44

src/pure.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import * as React from 'react'
22
import ReactDOM from 'react-dom'
33
import {
44
getQueriesForElement,

0 commit comments

Comments
 (0)