Skip to content

Commit c21722d

Browse files
Install Jest and Enzyme (#54)
* Install Jest and Enzyme and remove Mocha and Chai. Update node-sass version. * Tentative jest configuration. * Get Jest config in shape. Removed unneeded extensions from webpack defaults. Remove obsolete test config.
1 parent e1e8524 commit c21722d

File tree

7 files changed

+34
-57
lines changed

7 files changed

+34
-57
lines changed

__mocks__/fileMock.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// __mocks__/fileMock.js
2+
3+
module.exports = 'test-file-stub';

package.json

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"build": "NODE_ENV=development WEBPACK=cleandist webpack --progress --stats --config webpack.config.js",
1414
"build:watch": "NODE_ENV=development WEBPACK=cleandist webpack --progress --stats --config webpack.config.js --watch",
1515
"deploy": "NODE_ENV=production WEBPACK=cleandist webpack --progress --stats --config webpack.config.js",
16-
"test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive",
16+
"test": "node --harmony_proxies node_modules/.bin/jest",
1717
"test:watch": "npm run test -- --watch",
1818
"tasks:highlighter": "curl http://localhost:5000/api/highlighter_tasks/?format=json | python -m json.tool > pbs-highlighter/highlighter_tasks.json",
1919
"tasks:quiz": "curl http://localhost:5000/api/quiz_tasks/?format=json | python -m json.tool > pbs-quiz/quiz_tasks.json"
@@ -24,6 +24,7 @@
2424
"autoprefixer-loader": "^3.2.0",
2525
"babel-core": "^6.4.5",
2626
"babel-eslint": "^7.1.0",
27+
"babel-jest": "^18.0.0",
2728
"babel-loader": "^6.2.1",
2829
"babel-plugin-add-module-exports": "^0.2.1",
2930
"babel-plugin-transform-class-properties": "^6.19.0",
@@ -38,8 +39,6 @@
3839
"babel-register": "^6.16.3",
3940
"babel-require": "^1.0.1",
4041
"babel-runtime": "^6.3.19",
41-
"chai": "^3.5.0",
42-
"chai-immutable": "^1.5.3",
4342
"colors": "^1.1.2",
4443
"css-loader": "^0.26.0",
4544
"csswring": "^5.1.0",
@@ -49,6 +48,7 @@
4948
"eslint": "^3.10.2",
5049
"eslint-config-airbnb": "^13.0.0",
5150
"eslint-loader": "^1.6.1",
51+
"eslint-module-utils": "^2.0.0",
5252
"eslint-plugin-import": "^2.2.0",
5353
"eslint-plugin-jsx-a11y": "^2.2.3",
5454
"eslint-plugin-react": "^6.7.1",
@@ -58,13 +58,13 @@
5858
"file-loader": "^0.9.0",
5959
"fs-extra": "^1.0.0",
6060
"html-webpack-plugin": "^2.22.0",
61+
"identity-obj-proxy": "^3.0.0",
6162
"immutable": "^3.8.1",
6263
"imports-loader": "^0.6.3",
64+
"jest": "^18.1.0",
6365
"json-loader": "^0.5.1",
64-
"mocha": "^3.0.2",
65-
"mocha-webpack": "^0.7.0",
6666
"moment": "^2.15.2",
67-
"node-sass": "^3.0.0-beta.7",
67+
"node-sass": "^4.4.0",
6868
"normalizr": "^2.3.1",
6969
"on-build-webpack": "^0.1.0",
7070
"postcss-loader": "^1.1.1",
@@ -73,12 +73,14 @@
7373
"react": "^15.4.0",
7474
"react-addons-css-transition-group": "^15.4.0",
7575
"react-addons-shallow-compare": "^15.4.0",
76+
"react-addons-test-utils": "^15.4.2",
7677
"react-dates": "^4.0.0",
7778
"react-dom": "^15.4.0",
7879
"react-hot-loader": "^3.0.0-beta.6",
7980
"react-portal": "^3.0.0",
8081
"react-redux": "^4.2.1",
8182
"react-router": "^3.0.0",
83+
"react-test-renderer": "^15.4.2",
8284
"redux": "^3.2.1",
8385
"redux-devtools": "^3.1.0",
8486
"redux-thunk": "^2.1.0",
@@ -89,5 +91,19 @@
8991
"webpack": "^1.12.2",
9092
"webpack-dev-server": "^1.12.0"
9193
},
92-
"dependencies": {}
94+
"dependencies": {},
95+
"jest": {
96+
"verbose": true,
97+
"modulePaths": [
98+
"<rootDir>/app",
99+
"<rootDir>/vendor/bower_components"
100+
],
101+
"moduleFileExtensions": ["", "js", "jsx"],
102+
"moduleDirectories": ["node_modules", "web_modules"],
103+
"moduleNameMapper": {
104+
"^modernizr$": "<rootDir>/vendor/bower_components/modernizr/modernizr.js",
105+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
106+
"\\.(css|scss)$": "identity-obj-proxy"
107+
}
108+
}
93109
}

test/index.html

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/test_chai.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/test_helper.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

testem.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

webpack/base.config.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default {
8585
},
8686
root: [PATHS.app, PATHS.bowerPath],
8787
modulesDirectories: ['node_modules', 'web_modules'],
88-
extensions: ['', '.js', '.scss', 'hbs', 'tmpl', 'svg', 'woff', 'eot', 'svg', 'png']
88+
extensions: ['', '.js', '.jsx']
8989
},
9090
output: {
9191
path: PATHS.dist,
@@ -151,5 +151,11 @@ export default {
151151
// new webpack.optimize.DedupePlugin(),
152152
new webpack.optimize.OccurenceOrderPlugin()
153153
],
154-
noParse: [/node_modules/, new RegExp(PATHS.bowerPath)]
154+
noParse: [/node_modules/, new RegExp(PATHS.bowerPath)],
155+
externals: {
156+
'cheerio': 'window',
157+
'react/addons': true,
158+
'react/lib/ExecutionEnvironment': true,
159+
'react/lib/ReactContext': true
160+
}
155161
};

0 commit comments

Comments
 (0)