Add testing infrastructure using jest
Added simple test to illustrate how to use jest with react.
This commit is contained in:
parent
e2c13cd1db
commit
e53cbd0fc6
4 changed files with 58 additions and 15 deletions
|
|
@ -35,25 +35,13 @@ String.prototype.trunc = String.prototype.trunc || function(n){
|
|||
};
|
||||
|
||||
const {
|
||||
AppBar,
|
||||
AppCanvas,
|
||||
FontIcon,
|
||||
IconButton,
|
||||
EnhancedButton,
|
||||
NavigationClose,
|
||||
FloatingActionButton,
|
||||
Menu,
|
||||
MenuItem,
|
||||
Mixins,
|
||||
RaisedButton,
|
||||
FlatButton,
|
||||
Popover,
|
||||
Badge,
|
||||
TextField,
|
||||
Dialog,
|
||||
Styles,
|
||||
LeftNav,
|
||||
Paper} = mui
|
||||
Paper
|
||||
} = mui
|
||||
|
||||
const DefaultRawTheme = Styles.LightRawTheme
|
||||
|
||||
|
|
|
|||
17
app/components/__tests__/EntrySelector-test.jsx
Normal file
17
app/components/__tests__/EntrySelector-test.jsx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
jest.autoMockOff()
|
||||
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import TestUtils from 'react-addons-test-utils'
|
||||
|
||||
const EntrySelector = require('../EntrySelector').default
|
||||
|
||||
describe('EntrySelector', () => {
|
||||
|
||||
it('test jest', () => {
|
||||
var entrySelector = TestUtils.renderIntoDocument(
|
||||
<EntrySelector id="entry-selector" className="left inline fill-height" />
|
||||
)
|
||||
expect(entrySelector.state.entries.length).toEqual(0)
|
||||
})
|
||||
})
|
||||
12
jest/preprocessor.js
Normal file
12
jest/preprocessor.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
var babelJest = require('babel-jest');
|
||||
var webpackAlias = require('jest-webpack-alias');
|
||||
|
||||
module.exports = {
|
||||
process: function(src, filename) {
|
||||
if (filename.indexOf('node_modules') === -1) {
|
||||
src = babelJest.process(src, filename);
|
||||
src = webpackAlias.process(src, filename);
|
||||
}
|
||||
return src;
|
||||
}
|
||||
};
|
||||
28
package.json
28
package.json
|
|
@ -21,6 +21,7 @@
|
|||
},
|
||||
"client_certificate": "",
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"dev": "webpack-dev-server --progress --colors --port 8090",
|
||||
"serve": "./node_modules/.bin/http-server -p 8080",
|
||||
"start": "npm run serve | npm run dev",
|
||||
|
|
@ -149,6 +150,7 @@
|
|||
"main_html": "index.html",
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.5.1",
|
||||
"babel-jest": "*",
|
||||
"babel-loader": "^6.2.2",
|
||||
"babel-preset-es2015": "^6.5.0",
|
||||
"babel-preset-react": "^6.5.0",
|
||||
|
|
@ -157,10 +159,34 @@
|
|||
"babel-preset-stage-2": "^6.5.0",
|
||||
"babel-preset-stage-3": "^6.5.0",
|
||||
"http-server": "^0.8.4",
|
||||
"jest-cli": "*",
|
||||
"jest-webpack-alias": "^2.2.0",
|
||||
"react-addons-test-utils": "^0.14.7",
|
||||
"redux-devtools": "^3.1.1",
|
||||
"webpack": "*",
|
||||
"webpack-dev-server": "^1.11.0"
|
||||
},
|
||||
"keywords": [],
|
||||
"node_main": ""
|
||||
"node_main": "",
|
||||
"jest": {
|
||||
"scriptPreprocessor": "<rootDir>/jest/preprocessor.js",
|
||||
"unmockedModulePathPatterns": [
|
||||
"<rootDir>/node_modules/react",
|
||||
"<rootDir>/node_modules/material-ui",
|
||||
"<rootDir>/node_modules/react-dom",
|
||||
"<rootDir>/node_modules/react-addons-test-utils",
|
||||
"<rootDir>/node_modules/fbjs"
|
||||
],
|
||||
"testFileExtensions": [
|
||||
"jsx",
|
||||
"js",
|
||||
"es6"
|
||||
],
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"jsx",
|
||||
"json",
|
||||
"es6"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue