Fix Cheerio library import in webpack
authorFrank Bessou <frank.bessou@logilab.fr>
Thu, 06 Apr 2017 11:47:50 +0200
changeset 87 e788bdc3ea46
parent 86 52b73d0dacee
child 88 3075a8f89265
Fix Cheerio library import in webpack Cheerio was not loaded by webpack and tests using it could not pass. This was the case when calling render on an enzyme shallow wrapper.
package.json
webpack/test.config.js
--- a/package.json	Thu Apr 06 10:49:21 2017 +0200
+++ b/package.json	Thu Apr 06 11:47:50 2017 +0200
@@ -27,6 +27,7 @@
     "eslint": "^3.11.1",
     "eslint-plugin-react": "^6.7.1",
     "html-webpack-plugin": "^2.28.0",
+    "json-loader": "^0.5.4",
     "jsonary": "0.0.16",
     "karma": "^1.5.0",
     "karma-firefox-launcher": "^1.0.1",
--- a/webpack/test.config.js	Thu Apr 06 10:49:21 2017 +0200
+++ b/webpack/test.config.js	Thu Apr 06 11:47:50 2017 +0200
@@ -2,9 +2,10 @@
 const config = module.exports = require("./common.config");
 
 config.externals = config.externals || {};
+config.module.rules.push({test: /\.json$/, loader: 'json-loader'});
+
 
 config.externals = defaults(config.externals, {
-    'cheerio': 'window',
     'react/addons': 'react',
     'react/lib/ExecutionEnvironment': 'react',
     'react/lib/ReactContext': 'react',