Skip to content

chore: update React imports #811

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

Merged
merged 1 commit into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ afterAll(() => {

```jsx
// hidden-message.js
import React from 'react'
import * as React from 'react'

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

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

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

```jsx
// login.js
import React from 'react'
import * as React from 'react'

function Login() {
const [state, setState] = React.useReducer((s, a) => ({...s, ...a}), {
Expand All @@ -233,9 +233,7 @@ function Login() {
password: passwordInput.value,
}),
})
.then((r) =>
r.json().then((data) => (r.ok ? data : Promise.reject(data)))
)
.then(r => r.json().then(data => (r.ok ? data : Promise.reject(data))))
.then(
user => {
setState({loading: false, resolved: true, error: null})
Expand Down Expand Up @@ -276,15 +274,15 @@ export default Login
// again, these first two imports are something you'd normally handle in
// your testing framework configuration rather than importing them in every file.
import '@testing-library/jest-dom'
import React from 'react'
import * as React from 'react'
// import API mocking utilities from Mock Service Worker.
import {rest} from 'msw'
import {setupServer} from 'msw/node'
// import testing utilities
import {render, fireEvent, screen} from '@testing-library/react'
import Login from '../login'

const fakeUserResponse = { token: 'fake_user_token' }
const fakeUserResponse = {token: 'fake_user_token'}
const server = setupServer(
rest.post('/api/login', (req, res, ctx) => {
return res(ctx.json(fakeUserResponse))
Expand Down Expand Up @@ -400,8 +398,8 @@ principles:
`react-dom`.
3. Utility implementations and APIs should be simple and flexible.

Most importantly, we want React Testing Library to be pretty
light-weight, simple, and easy to understand.
Most importantly, we want React Testing Library to be pretty light-weight,
simple, and easy to understand.

## Docs

Expand All @@ -410,8 +408,7 @@ light-weight, simple, and easy to understand.

## Issues

Looking to contribute? Look for the [Good First Issue][good-first-issue]
label.
Looking to contribute? Look for the [Good First Issue][good-first-issue] label.

### 🐛 Bugs

Expand Down Expand Up @@ -607,6 +604,7 @@ Thanks goes to these people ([emoji key][emojis]):

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors][all-contributors] specification.
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/act.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import {render, fireEvent, screen} from '../'

test('render calls useEffect immediately', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/auto-cleanup-skip.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'

let render
beforeAll(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/auto-cleanup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import {render} from '../'

// This just verifies that by importing RTL in an
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/cleanup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import {render, cleanup} from '../'

test('cleans up the document', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/debug.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import {render, screen} from '../'

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/end-to-end.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import {render, waitForElementToBeRemoved, screen} from '../'

const fetchAMessage = () =>
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/events.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import {render, fireEvent} from '../'

const eventTypes = [
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/multi-base.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import {render} from '../'

// these are created once per test suite and reused for each case
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/render.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import ReactDOM from 'react-dom'
import {render, screen} from '../'

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/rerender.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import {render} from '../'

test('rerender will re-render the element', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/stopwatch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import {render, fireEvent, screen} from '../'

class StopWatch extends React.Component {
Expand Down
2 changes: 1 addition & 1 deletion src/act-compat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import ReactDOM from 'react-dom'
import * as testUtils from 'react-dom/test-utils'

Expand Down
2 changes: 1 addition & 1 deletion src/pure.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import ReactDOM from 'react-dom'
import {
getQueriesForElement,
Expand Down