From c0b30bc30de6197bbe77b8dcf6d8a97d950e5dc3 Mon Sep 17 00:00:00 2001 From: Jason Galea Date: Sat, 19 Dec 2015 00:16:04 +1000 Subject: [PATCH] Update to babel 6 #78 - tests pass with React 13 & 14 - npm run travis produces coverage - npm link works - use airbnb Babel6 preset - modify react-compat to export functions individually - update test commands to use babel-core --- .babelrc | 3 +++ package.json | 18 +++++++++++------- src/ReactWrapperComponent.jsx | 2 +- src/react-compat.js | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 .babelrc diff --git a/.babelrc b/.babelrc new file mode 100644 index 000000000..e0aceaae1 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["airbnb"] +} diff --git a/package.json b/package.json index 66f71341f..e3dc18e88 100644 --- a/package.json +++ b/package.json @@ -10,12 +10,12 @@ "version": "npm run build", "clean": "rimraf build", "lint": "eslint src/**", - "test": "mocha --compilers js:babel/register --recursive src/**/__tests__/*.js", + "test": "mocha --compilers js:babel-core/register --recursive src/**/__tests__/*.js", "check": "npm run lint && npm run test:all", "build": "babel src --out-dir build", - "test:watch": "mocha --compilers js:babel/register --recursive src/**/__tests__/*.js --watch", - "test:describeWithDOMOnly": "mocha --compilers js:babel/register --recursive src/**/__tests__/describeWithDOM/describeWithDOMOnly-spec.js", - "test:describeWithDOMSkip": "mocha --compilers js:babel/register --recursive src/**/__tests__/describeWithDOM/describeWithDOMSkip-spec.js", + "test:watch": "mocha --compilers js:babel-core/register --recursive src/**/__tests__/*.js --watch", + "test:describeWithDOMOnly": "mocha --compilers js:babel-core/register --recursive src/**/__tests__/describeWithDOM/describeWithDOMOnly-spec.js", + "test:describeWithDOMSkip": "mocha --compilers js:babel-core/register --recursive src/**/__tests__/describeWithDOM/describeWithDOMSkip-spec.js", "test:all": "npm run react:13 && npm test && npm run test:describeWithDOMOnly && npm run test:describeWithDOMSkip && npm run react:14 && npm test && npm run test:describeWithDOMOnly && npm run test:describeWithDOMSkip", "react:clean": "rimraf node_modules/react node_modules/react-dom node_modules/react-addons-test-utils", "react:13": "npm run react:clean && npm i react@0.13", @@ -25,7 +25,7 @@ "docs:build": "npm run docs:prepare && gitbook build", "docs:watch": "npm run docs:prepare && gitbook serve", "docs:publish": "npm run docs:clean && npm run docs:build && cd _book && git init && git commit --allow-empty -m 'update book' && git fetch https://github.com/airbnb/enzyme.git gh-pages && git checkout -b gh-pages && git add . && git commit -am 'update book' && git push https://github.com/airbnb/enzyme.git gh-pages --force", - "travis": "istanbul cover _mocha -- --compilers js:babel/register --recursive src/**/__tests__/*.js" + "travis": "babel-istanbul cover --report html _mocha -- --recursive src/**/__tests__/*.js" }, "repository": { "type": "git", @@ -55,8 +55,12 @@ "underscore": "^1.8.3" }, "devDependencies": { - "babel": "^5.8.21", + "babel-cli": "^6.3.17", + "babel-core": "^6.3.21", "babel-eslint": "^4.1.4", + "babel-istanbul": "^0.5.9", + "babel-preset-airbnb": "^1.0.1", + "babel-register": "^6.3.13", "chai": "^3.2.0", "coveralls": "^2.11.4", "eslint": "^1.10.3", @@ -64,7 +68,7 @@ "eslint-plugin-react": "^3.14.0", "gitbook-cli": "^1.0.0", "istanbul": "^0.4.0", - "mocha": "^2.2.5", + "mocha": "^2.3.4", "rimraf": "^2.4.3" }, "peerDependencies": { diff --git a/src/ReactWrapperComponent.jsx b/src/ReactWrapperComponent.jsx index 698477a72..590689eb6 100644 --- a/src/ReactWrapperComponent.jsx +++ b/src/ReactWrapperComponent.jsx @@ -72,7 +72,7 @@ export default function createWrapperComponent(node, options = {}) { // For full rendering, we are using this wrapper component to provide context if it is // specified in both the options AND the child component defines `contextTypes` statically. // In that case, we define both a `getChildContext()` function and a `childContextTypes` prop. - Object.assign(spec, { + objectAssign(spec, { childContextTypes: node.type.contextTypes, getChildContext() { return this.state.context; diff --git a/src/react-compat.js b/src/react-compat.js index b01413c6e..5f8e8fbe7 100644 --- a/src/react-compat.js +++ b/src/react-compat.js @@ -88,7 +88,7 @@ const { findAllInRenderedTree, } = TestUtils; -export default { +export { createShallowRenderer, renderToStaticMarkup, renderIntoDocument,