From 1b1f3f6b7b77a62942b39e35662632b96b55cb2e Mon Sep 17 00:00:00 2001 From: Tim Dorr Date: Thu, 4 Feb 2016 23:38:47 -0500 Subject: [PATCH] Clean up some testing framework stuff. Fix Firefox with babel-polyfill. --- karma.conf.js | 33 +++++++++++++++++---------------- package.json | 4 +++- test/browser/index.js | 2 ++ 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 027abcb..546243e 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,12 +1,13 @@ -var path = require('path'); -var webpack = require('webpack'); +'use strict' + +const path = require('path') module.exports = function (config) { - var runCoverage = process.env.COVERAGE === 'true'; + let runCoverage = process.env.COVERAGE === 'true' - var coverageLoaders = []; - var coverageReporters = []; + let coverageLoaders = [] + let coverageReporters = [] if (runCoverage) { coverageLoaders.push({ @@ -15,7 +16,7 @@ module.exports = function (config) { loader: 'isparta' }), - coverageReporters.push('coverage'); + coverageReporters.push('coverage') } config.set({ @@ -39,19 +40,19 @@ module.exports = function (config) { module: { preLoaders: [ { + loader: 'babel', test: /\.js$/, - exclude: [ - path.resolve('node_modules/') - ], - loader: 'babel' - }, + include: [ + path.resolve('src/'), + path.resolve('test/') + ] + + } ].concat(coverageLoaders) } }, - webpackServer: { - noInfo: true - }, + webpackServer: {}, coverageReporter: { reporters: [ @@ -59,5 +60,5 @@ module.exports = function (config) { { type: 'json', subdir: 'browser-coverage', file: 'coverage.json' } ] } - }); -}; + }) +} diff --git a/package.json b/package.json index b7aecb1..a316cff 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "build": "mkdir -p lib && babel ./src -d lib", "lint": "eslint examples src test", "test": "npm run lint && npm run test:node && npm run test:browser", - "test:node": "mocha --compilers js:babel-core/register --recursive ./test/node", + "test:node": "mocha --compilers js:babel-register --recursive ./test/node", "test:browser": "karma start", "test:cov": "npm run test:cov:browser && npm run test:cov:node && npm run test:cov:report", "test:cov:node": "babel-node $(npm bin)/isparta cover $(npm bin)/_mocha report --dir ./coverage/node-coverage -- --recursive ./test/node", @@ -41,8 +41,10 @@ "babel-core": "^6.2.1", "babel-eslint": "^4.1.6", "babel-loader": "^6.2.0", + "babel-polyfill": "^6.3.14", "babel-preset-es2015": "^6.3.13", "babel-preset-stage-1": "^6.3.13", + "babel-register": "^6.4.3", "eslint": "^1.10.3", "eslint-config-rackt": "^1.1.1", "eslint-plugin-react": "^3.15.0", diff --git a/test/browser/index.js b/test/browser/index.js index 93e51c7..e246613 100644 --- a/test/browser/index.js +++ b/test/browser/index.js @@ -1,3 +1,5 @@ +import 'babel-polyfill' + import { hashHistory, browserHistory } from 'react-router' import createTests from '../createTests.js'