Skip to content

Commit e08dba0

Browse files
committed
Merge pull request kriasoft#484 from cpojer/master
Update to Jest 0.9.0 and add an example with enzyme.
2 parents 57d3ee1 + a8d149c commit e08dba0

File tree

5 files changed

+39
-30
lines changed

5 files changed

+39
-30
lines changed

.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"globals": {
55
"__DEV__": true
66
},
7+
"env": {
8+
"browser": true,
9+
"jest": true
10+
},
711
"rules": {
812
"no-confusing-arrow": 0,
913
"react/jsx-quotes": 0,

package.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"autoprefixer": "^6.3.3",
4343
"babel-cli": "^6.6.0",
4444
"babel-eslint": "^5.0.0",
45+
"babel-jest": "^9.0.0",
4546
"babel-loader": "^6.2.4",
4647
"babel-plugin-react-transform": "^2.0.0",
4748
"babel-plugin-transform-runtime": "^6.6.0",
@@ -53,17 +54,19 @@
5354
"css-loader": "^0.23.1",
5455
"csscomb": "^3.1.8",
5556
"del": "^2.2.0",
57+
"enzyme": "^2.0.0",
5658
"eslint": "^2.2.0",
5759
"eslint-config-airbnb": "^6.0.2",
5860
"eslint-loader": "^1.3.0",
5961
"eslint-plugin-react": "^4.1.0",
62+
"estraverse-fb": "^1.3.1",
6063
"extend": "^3.0.0",
6164
"file-loader": "^0.8.5",
6265
"gaze": "^0.5.2",
6366
"git-repository": "^0.1.1",
6467
"glob": "^7.0.0",
6568
"jade-loader": "^0.8.0",
66-
"jest-cli": "^0.8.2",
69+
"jest-cli": "^0.9.0",
6770
"jscs": "^2.11.0",
6871
"json-loader": "^0.5.4",
6972
"mkdirp": "^0.5.1",
@@ -74,6 +77,7 @@
7477
"postcss-scss": "^0.1.6",
7578
"precss": "^1.4.0",
7679
"raw-loader": "^0.5.1",
80+
"react-addons-test-utils": "^0.14.7",
7781
"react-transform-catch-errors": "^1.0.2",
7882
"react-transform-hmr": "^1.0.2",
7983
"redbox-react": "^1.2.2",
@@ -85,10 +89,16 @@
8589
},
8690
"jest": {
8791
"rootDir": "./src",
88-
"scriptPreprocessor": "../preprocessor.js",
92+
"testPathDirs": [
93+
"<rootDir>",
94+
"<rootDir>/../test/"
95+
],
96+
"moduleNameMapper": {
97+
"\\.scss$": "SCSSStub"
98+
},
8999
"unmockedModulePathPatterns": [
90-
"fbjs",
91-
"react"
100+
"react",
101+
"enzyme"
92102
]
93103
},
94104
"scripts": {

preprocessor.js

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
jest.unmock('../App');
2+
3+
import App from '../App';
4+
import React from 'react';
5+
import { shallow } from 'enzyme';
6+
7+
describe('App', () => {
8+
it('renders children correctly', () => {
9+
const wrapper = shallow(
10+
<App context={{ insertCss: () => {} }}>
11+
<div className="child" />
12+
</App>
13+
);
14+
expect(wrapper.contains(<div className="child" />)).toBe(true);
15+
});
16+
});

test/stubs/SCSSStub.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* @providesModule SCSSStub
3+
*/
4+
5+
module.exports = {};

0 commit comments

Comments
 (0)