Skip to content

Commit

Permalink
Update karma cofig to be compatible with react@15.5
Browse files Browse the repository at this point in the history
  • Loading branch information
nfcampos authored and ljharb committed Apr 12, 2017
1 parent ec7bbc5 commit 3ff9832
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions karma.conf.js
Expand Up @@ -4,6 +4,36 @@ require('babel-register');

var IgnorePlugin = require('webpack').IgnorePlugin;
var REACT013 = require('./src/version').REACT013;
var REACT155 = require('./src/version').REACT155;

function getPlugins() {
var plugins = [];

/*
this list of conditional IgnorePlugins mirrors the conditional
requires in src/react-compat.js and exists to avoid error
output from the webpack compilation
*/

if (!REACT013) {
plugins.push(new IgnorePlugin(/react\/lib\/ExecutionEnvironment/));
plugins.push(new IgnorePlugin(/react\/lib\/ReactContext/));
plugins.push(new IgnorePlugin(/react\/addons/));
}
if (REACT013) {
plugins.push(new IgnorePlugin(/react-dom/));
}
if (REACT013 || REACT155) {
plugins.push(new IgnorePlugin(/react-addons-test-utils/));
}
if (!REACT155) {
plugins.push(new IgnorePlugin(/react-test-renderer/));
plugins.push(new IgnorePlugin(/react-dom\/test-utils/));
plugins.push(new IgnorePlugin(/create-react-class/));
}

return plugins
}

module.exports = function karma(config) {
config.set({
Expand All @@ -29,11 +59,7 @@ module.exports = function karma(config) {
reporters: ['dots'],

files: [
'test/*.{jsx,js}',
],

exclude: [
'test/_*.{jsx,js}',
'test/*-spec.{jsx,js}',
],

browsers: [
Expand Down Expand Up @@ -71,18 +97,7 @@ module.exports = function karma(config) {
},
],
},
plugins: [
/*
this list of conditional IgnorePlugins mirrors the conditional
requires in src/react-compat.js and exists to avoid error
output from the webpack compilation
*/
!REACT013 && new IgnorePlugin(/react\/lib\/ExecutionEnvironment/),
!REACT013 && new IgnorePlugin(/react\/lib\/ReactContext/),
!REACT013 && new IgnorePlugin(/react\/addons/),
REACT013 && new IgnorePlugin(/react-dom/),
REACT013 && new IgnorePlugin(/react-addons-test-utils/),
].filter(function filterPlugins(plugin) { return plugin !== false; }),
plugins: getPlugins(),
},

webpackServer: {
Expand Down

0 comments on commit 3ff9832

Please sign in to comment.