[develop] environment setup for testing (#4)

* add yarn.lock

* test environment setup with jest

* allow eslint to suit for jest

* run lint before starting testing

* disable deprecated rule of 'react/jsx-space-before-closing'

* add CONTRIBUTING document

* specify how to start testing

* add Enzyme for React testing

* add testing template for bootstrap-table
This commit is contained in:
ChunMing, Chen
2017-08-19 06:01:17 -05:00
committed by Allen
parent 4d6ad8d7e8
commit 23cb0fd160
6 changed files with 6029 additions and 5 deletions
+5 -1
View File
@@ -3,7 +3,7 @@
"parser": "babel-eslint",
"env": {
"browser": true,
"jasmine": true,
"jest": true,
"node": true
},
"plugins": [
@@ -14,6 +14,10 @@
"react/jsx-curly-spacing": 0,
"react/forbid-prop-types": 0,
"react/jsx-filename-extension": 0,
"react/jsx-space-before-closing": 0,
"react/jsx-tag-spacing": ["error", { "beforeSelfClosing": "always" }],
"import/extensions": 0, // skip import extensions
"import/no-unresolved": [1, { "ignore": ["^react-bootstrap-table"] }], // monorepo setup
"import/prefer-default-export": 0,
"import/no-extraneous-dependencies": 0
},
+15 -1
View File
@@ -1 +1,15 @@
node_modules
# dependencies
node_modules
# testing
/coverage
.eslintcache
# misc
.DS_Store
.vscode
# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
+17
View File
@@ -0,0 +1,17 @@
# Contributing to react-bootstrap-table2
## Commands
### Testing
In order to run the tests
`yarn test`
testing with `watch mode`
`yarn test:watch`
see the coverage report
`yarn test:coverage`
+23 -3
View File
@@ -5,7 +5,11 @@
"main": "index.js",
"scripts": {
"start": "node -r babel-register ./node_modules/.bin/webpack-dev-server --config webpack.config.babel.js",
"test": "echo \"Error: no test specified\" && exit 1"
"lint": "eslint ./packages --ext .js --ext .jsx --ignore-path .gitignore",
"pretest": "yarn lint --cache",
"test": "jest",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch"
},
"repository": {
"type": "git",
@@ -25,6 +29,7 @@
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.24.1",
"enzyme": "^2.9.1",
"eslint": "^4.5.0",
"eslint-config-airbnb": "^14.1.0",
"eslint-loader": "^1.9.0",
@@ -32,7 +37,10 @@
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^7.2.1",
"html-webpack-plugin": "^2.30.1",
"jest": "^20.0.4",
"jest-babel": "^1.0.1",
"lerna": "^2.0.0",
"react-test-renderer": "^15.6.1",
"webpack": "^3.5.4",
"webpack-dev-server": "^2.7.1"
},
@@ -42,8 +50,20 @@
"react-dom": "^15.6.1"
},
"peerDependencies": {
"prop-types": "^15.0.0",
"react": "^15.0.0",
"react-dom": "^15.0.0",
"prop-types": "^15.0.0"
"react-dom": "^15.0.0"
},
"jest": {
"collectCoverageFrom": [
"packages/**/*.js"
],
"roots": [
"<rootDir>/packages"
],
"testEnvironment": "node",
"testMatch": [
"**/test/*.js"
]
}
}
@@ -0,0 +1,15 @@
import React from 'react';
import { shallow } from 'enzyme';
import BootstrapTable from '../src/bootstrap-table';
describe('BootstrapTable', () => {
describe('render', () => {
test('it should render DOM correctly', () => {
const wrapper = shallow(<BootstrapTable />);
expect(wrapper.length).toBe(1);
expect(wrapper.find('ul').length).toBe(1);
});
});
});
+5954
View File
File diff suppressed because it is too large Load Diff