Permalink
Browse files

chore(tests): Use Jest for tests (#302)

* chore: Switched to Jest testing framework
* chore: Removed a temp test for a React bug that was fixed 15.2.1
* chore(build): Run tests on the dist after the build
* chore(CI): Integrate codecov.io with Travis CI
* docs: Added codecov badge
* chore(CI): Exclude dist and spec from codeclimate
  • Loading branch information...
1 parent 62645e7 commit b2a4486fa93ea7a7de97f9e6fe75263ed4a4c100 @okonet committed on GitHub Dec 10, 2016
Showing with 126 additions and 108 deletions.
  1. +3 −1 .codeclimate.yml
  2. +1 −1 .eslintrc
  3. +2 −0 .gitignore
  4. +1 −0 .travis.yml
  5. +2 −1 README.md
  6. +0 −18 mocha-environment.js
  7. +7 −6 package.json
  8. +71 −81 src/{test.js → index.spec.js}
  9. +7 −0 testSetup.js
  10. +32 −0 wallaby.config.js
View
@@ -10,4 +10,6 @@ engines:
ratings:
paths:
- "**.js"
-#exclude_paths:
+exclude_paths:
+ - "dist/"
+ - "src/*.spec.js"
View
@@ -4,7 +4,7 @@
"env": {
"browser": true, // We write for browser
"node": true, // using CommonJS imports
- "mocha": true, // We use Mocha for tests
+ "jest": true, // We use Mocha for tests
"es6": true // And we use ES6 features
},
"ecmaFeatures": {
View
@@ -12,3 +12,5 @@ dist
.idea
.DS_Store
+
+coverage
View
@@ -12,6 +12,7 @@ before_install:
before_script:
- npm prune
after_success:
+ - bash <(curl -s https://codecov.io/bash)
- npm run semantic-release
branches:
except:
View
@@ -1,4 +1,5 @@
-react-dropzone [![Build Status](https://travis-ci.org/okonet/react-dropzone.svg?branch=master)](https://travis-ci.org/okonet/react-dropzone) [![npm version](https://badge.fury.io/js/react-dropzone.svg)](https://badge.fury.io/js/react-dropzone)
+react-dropzone [![Build Status](https://travis-ci.org/okonet/react-dropzone.svg?branch=master)](https://travis-ci.org/okonet/react-dropzone) [![npm version](https://badge.fury.io/js/react-dropzone.svg)](https://badge.fury.io/js/react-dropzone) [![codecov](https://codecov.io/gh/okonet/react-dropzone/branch/master/graph/badge.svg)](https://codecov.io/gh/okonet/react-dropzone)
+
==============
Simple HTML5 drag-drop zone for files with React.js.
View
@@ -1,18 +0,0 @@
-/* eslint prefer-template: 0 */
-/* eslint object-shorthand: 0 */
-
-// import es6
-require('babel-register');
-
-// jsdom
-var jsdom = require('jsdom'); // eslint-disable-line
-
-global.document = jsdom.jsdom('<!doctype html><html><body></body></html>');
-global.window = global.document.defaultView;
-global.navigator = global.window.navigator;
-
-global.window.URL = {
- createObjectURL: function createObjectURL(arg) {
- return 'data://' + arg.name;
- }
-};
View
@@ -5,8 +5,8 @@
"scripts": {
"clean": "rimraf ./dist",
"build": "npm run clean && webpack",
- "prepublish": "npm run build",
- "test": "npm run eslint:src && mocha --require ./mocha-environment.js ./src/test.js",
+ "prepublish": "NODE_ENV=production npm run build && jest",
+ "test": "npm run eslint:src && jest --coverage",
"eslint:src": "eslint ./src ./*.js",
"eslint:fix": "eslint --fix",
"git:add": "git add",
@@ -24,6 +24,9 @@
"pre-commit": [
"lint-staged"
],
+ "jest": {
+ "setupTestFrameworkScriptFile": "<rootDir>/testSetup.js"
+ },
"keywords": [
"react-component",
"react",
@@ -55,22 +58,21 @@
"babel-cli": "^6.9.0",
"babel-core": "^6.9.1",
"babel-eslint": "^6.0.4",
+ "babel-jest": "^17.0.2",
"babel-loader": "^6.2.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"babel-register": "^6.9.0",
- "chai": "^3.4.1",
"cz-conventional-changelog": "^1.2.0",
"eslint": "^2.11.0",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.8.1",
"eslint-plugin-jsx-a11y": "^1.2.2",
"eslint-plugin-react": "^5.1.1",
- "jsdom": "^9.2.1",
+ "jest": "^17.0.3",
"lint-staged": "^3.2.1",
- "mocha": "^2.5.3",
"npm-check": "^5.2.1",
"pre-commit": "^1.1.3",
"react": "^15.2.0",
@@ -79,7 +81,6 @@
"react-testutils-additions": "^15.0.0",
"rimraf": "^2.5.2",
"semantic-release": "^4.3.5",
- "semver": "^5.3.0",
"sinon": "^1.17.4",
"webpack": "^1.13.1"
},
Oops, something went wrong.

0 comments on commit b2a4486

Please sign in to comment.