Skip to content

Commit

Permalink
Initial Karma/Chrome config, get Button.test passing
Browse files Browse the repository at this point in the history
  • Loading branch information
jbinto committed Jan 23, 2016
1 parent 0951e7f commit 83a1d1d
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 2 deletions.
25 changes: 25 additions & 0 deletions karma.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var path = require('path');
var webpackConfig = require('./webpack/webpack.test.babel');

module.exports = function(config) {
config.set({
frameworks: ['mocha', 'chai'],

browsers: process.env.TRAVIS
? ['ChromeTravis']
: ['Chrome'],

autoWatch: process.env.TRAVIS ? false : true,
singleRun: process.env.TRAVIS ? true : false,

files: [
'app/components/Button/Button.test.js'
],

preprocessors: {
['app/components/Button/Button.test.js']: ['webpack', 'sourcemap'],
},

webpack: webpackConfig
});
};
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
"html-webpack-plugin": "^2.7.1",
"ip": "^1.1.0",
"json-loader": "^0.5.4",
"karma": "^0.13.19",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^0.2.2",
"karma-mocha": "^0.2.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.7.0",
"lint-staged": "^0.1.1",
"mocha": "^2.3.4",
"ngrok": "^0.2.2",
Expand All @@ -67,8 +73,9 @@
"lint": "eslint .",
"lint:staged": "eslint-staged",
"pretest": "npm run lint",
"test": "NODE_ENV=test mocha --compilers js:babel-core/register,css:css-modules-require-hook --require ./webpack/testHelper.js --recursive 'app/**/*.test.js'",
"test:watch": "NODE_ENV=test npm test -- --watch",
"test": "NODE_ENV=test karma start karma.config.js",
"test:mocha": "NODE_ENV=test mocha --compilers js:babel-core/register,css:css-modules-require-hook --require ./webpack/testHelper.js --recursive 'app/**/*.test.js'",
"test:mocha:watch": "NODE_ENV=test npm test -- --watch",
"start": "NODE_ENV=development node webpack/server.dev.js",
"prebuild": "npm run test",
"build": "NODE_ENV=production webpack --config webpack/webpack.prod.babel.js --progress --colors -p",
Expand Down
44 changes: 44 additions & 0 deletions webpack/webpack.test.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* TEST WEBPACK CONFIGURATION
*/

module.exports = {
devtool: 'inline-source-map',
module: {
// Some libraries don't like being run through babel.
// If they gripe, put them here.
noParse: [
/node_modules\/sinon/,
/node_modules\/acorn/,
],
loaders: [
{ test: /\.js$/, loader: 'babel', exclude: [/node_modules/], },
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.css$/, loader: 'null-loader' },
]
},
// Some node_modules pull in Node-specific dependencies.
// Since we're running in a browser we have to stub them out. See:
// https://webpack.github.io/docs/configuration.html#node
// https://github.com/webpack/node-libs-browser/tree/master/mock
// https://github.com/webpack/jade-loader/issues/8#issuecomment-55568520
node: {
fs: 'empty',
child_process: 'empty',
net: 'empty',
tls: 'empty',
},
// required for enzyme to work properly
externals: {
jsdom: 'window',
cheerio: 'window',
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': 'window'
},
resolve: {
alias: {
// required for enzyme to work properly
sinon: 'sinon/pkg/sinon'
},
},
};

0 comments on commit 83a1d1d

Please sign in to comment.