This repository has been archived by the owner on Jan 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 490
Merged
2.9.0 #220
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9e4589f
Merge pull request #165 from johnnyreilly/master
wmonk 05d5a6c
Merge pull request #199 from DorianGrey/master
DorianGrey 586a50f
Merge pull request #201 from StefanSchoof/patch-1
DorianGrey 10d283e
Merge pull request #204 from StefanSchoof/patch-1
DorianGrey cc52d21
Fix package.json
wmonk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1244,9 +1244,9 @@ There is a broad spectrum of component testing techniques. They range from a “ | |
|
||
Different projects choose different testing tradeoffs based on how often components change, and how much logic they contain. If you haven’t decided on a testing strategy yet, we recommend that you start with creating simple smoke tests for your components: | ||
|
||
```js | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
```ts | ||
import * as React from 'react'; | ||
import * asReactDOM from 'react-dom'; | ||
import App from './App'; | ||
|
||
it('renders without crashing', () => { | ||
|
@@ -1255,26 +1255,34 @@ it('renders without crashing', () => { | |
}); | ||
``` | ||
|
||
This test mounts a component and makes sure that it didn’t throw during rendering. Tests like this provide a lot value with very little effort so they are great as a starting point, and this is the test you will find in `src/App.test.js`. | ||
This test mounts a component and makes sure that it didn’t throw during rendering. Tests like this provide a lot value with very little effort so they are great as a starting point, and this is the test you will find in `src/App.test.tsx`. | ||
|
||
When you encounter bugs caused by changing components, you will gain a deeper insight into which parts of them are worth testing in your application. This might be a good time to introduce more specific tests asserting specific expected output or behavior. | ||
|
||
If you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). To install it, run: | ||
|
||
```sh | ||
npm install --save enzyme react-test-renderer | ||
npm install --save-dev enzyme @types/enzyme enzyme-adapter-react-16 @types/enzyme-adapter-react-16 react-test-renderer @types/react-test-renderer | ||
``` | ||
|
||
Alternatively you may use `yarn`: | ||
|
||
```sh | ||
yarn add enzyme react-test-renderer | ||
yarn add --dev enzyme @types/enzyme enzyme-adapter-react-16 @types/enzyme-adapter-react-16 react-test-renderer @types/react-test-renderer | ||
``` | ||
|
||
#### `src/setupTests.ts` | ||
```ts | ||
import * as Enzyme from 'enzyme'; | ||
import * as Adapter from 'enzyme-adapter-react-16'; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
``` | ||
|
||
You can write a smoke test with it too: | ||
|
||
```js | ||
import React from 'react'; | ||
```ts | ||
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import App from './App'; | ||
|
||
|
@@ -1289,8 +1297,8 @@ You can read the [Enzyme documentation](http://airbnb.io/enzyme/) for more testi | |
|
||
Here is an example from Enzyme documentation that asserts specific output, rewritten to use Jest matchers: | ||
|
||
```js | ||
import React from 'react'; | ||
```ts | ||
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import App from './App'; | ||
|
||
|
@@ -1323,7 +1331,7 @@ Alternatively you may use `yarn`: | |
yarn add jest-enzyme | ||
``` | ||
|
||
Import it in [`src/setupTests.js`](#initializing-test-environment) to make its matchers available in every test: | ||
Import it in [`src/setupTests.ts`](#initializing-test-environment) to make its matchers available in every test: | ||
|
||
```js | ||
import 'jest-enzyme'; | ||
|
@@ -1346,12 +1354,12 @@ and then use them in your tests like you normally do. | |
|
||
>Note: this feature is available with `[email protected]` and higher. | ||
|
||
If your app uses a browser API that you need to mock in your tests or if you just need a global setup before running your tests, add a `src/setupTests.js` to your project. It will be automatically executed before running your tests. | ||
If your app uses a browser API that you need to mock in your tests or if you just need a global setup before running your tests, add a `src/setupTests.ts` to your project. It will be automatically executed before running your tests. | ||
|
||
For example: | ||
|
||
#### `src/setupTests.js` | ||
```js | ||
#### `src/setupTests.ts` | ||
```ts | ||
const localStorageMock = { | ||
getItem: jest.fn(), | ||
setItem: jest.fn(), | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space missing