Skip to content

Commit f2b7559

Browse files
committed
minor refactoring
just to keep the same style across the docs
1 parent 7f2d1a3 commit f2b7559

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

docs/guides/testing.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
React Router Testing With Jest
22
====================
3-
Testing has become much easier since React Router version 1.x. For Testing prior React Router versions, see [Old testing docs](https://github.com/rackt/react-router/blob/57543eb41ce45b994a29792d77c86cc10b51eac9/docs/guides/testing.md)
3+
Testing has become much easier since React Router version 1.x. For Testing prior React Router versions, see [Old testing docs](https://github.com/rackt/react-router/blob/57543eb41ce45b994a29792d77c86cc10b51eac9/docs/guides/testing.md).
44

55
It is recommended that you read the following two tutorials prior:
66
- [Jest Getting Started docs](https://facebook.github.io/jest/docs/getting-started.html)
@@ -12,34 +12,34 @@ Testing with React-Router 1.x should just work. But if you are having issues see
1212
Updating from testing setup from React-Router 0.x to 1.x
1313
----------------------------------------------
1414
Firstly, ensure you are using at least the following versions of each package.
15-
- "react": "^0.14.0"
16-
- "react-dom": "^0.14.0"
17-
- "react-router": "^1.0.0"
18-
- "react-addons-test-utils": "^0.14.0"
19-
- "jest-cli": "^0.5.10"
20-
- "babel-jest": "^5.3.0"
15+
- `"react": "^0.14.0"`
16+
- `"react-dom": "^0.14.0"`
17+
- `"react-router": "^1.0.0"`
18+
- `"react-addons-test-utils": "^0.14.0"`
19+
- `"jest-cli": "^0.5.10"`
20+
- `"babel-jest": "^5.3.0"`
2121

2222
Also, make sure you are using node 4.x
2323

2424
In prior setups, react-tools was needed. This is not longer the case. You will need to remove it from your package.json and environment.
2525

26-
```
26+
```json
2727
"react-tools": "~0.13.3",
2828
```
2929

3030
Lastly, anywhere you have the following, needs to be replaced with this:
3131

32-
```
33-
var React = require('react/addons');
34-
var TestUtils = React.addons.TestUtils;
32+
```js
33+
var React = require('react/addons');
34+
var TestUtils = React.addons.TestUtils;
3535
```
3636

3737
with this:
3838

39-
```
40-
var TestUtils = require('react-addons-test-utils');
41-
var ReactDOM = require('react-dom');
42-
var React = require('react');
39+
```js
40+
var TestUtils = require('react-addons-test-utils');
41+
var ReactDOM = require('react-dom');
42+
var React = require('react');
4343
```
4444

4545
Make sure you do an npm clean, install, etc. and make sure you add react-addons-test-utils and react-dom to your unmocked paths.
@@ -113,13 +113,17 @@ The test for that component:
113113
```js
114114
//../components/__tests__/BasicPage-test.js
115115

116+
// NOTE: cannot use es6 modules syntax because
117+
// jest.dontMock & jest.autoMockOff()
118+
// do not understand ES6 modules yet
119+
116120
jest.dontMock('../BasicPage');
117121

118122
describe('BasicPage', function() {
119-
let BasicPage = require('../BasicPage');
120-
let TestUtils = require('react-addons-test-utils');
121-
let ReactDOM = require('react-dom');
122-
let React = require('react');
123+
let BasicPage = require('../BasicPage');
124+
let TestUtils = require('react-addons-test-utils');
125+
let ReactDOM = require('react-dom');
126+
let React = require('react');
123127

124128
it('renders the Login button if not logged in', function() {
125129
let page = TestUtils.renderIntoDocument(<BasicPage />);

0 commit comments

Comments
 (0)