Skip to content

Commit

Permalink
Merge and resolve master
Browse files Browse the repository at this point in the history
  • Loading branch information
Chase Adams committed Dec 17, 2015
2 parents e876189 + 6ea8fc6 commit 89d6ac7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
2 changes: 2 additions & 0 deletions config/eslint/.eslintrc-react-test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ globals:
document: false
expect: false
sandbox: false
# this will by removed by
# https://gecgithub01.walmart.com/electrode/electrode-archetype-react-component/issues/10
sinon: false
Element: false
rules:
Expand Down
7 changes: 7 additions & 0 deletions config/karma/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ require("babel-core/polyfill");
/*globals window:false*/
var chai = require("chai");
var sinonChai = require("sinon-chai");
/*
* We need a global sinon to maintain compatibility
* with existing test suites. However, this will be
* removed in the future and is being tracked by
* https://gecgithub01.walmart.com/electrode/electrode-archetype-react-component/issues/10
*/
window.sinon = require("sinon");

// --------------------------------------------------------------------------
// Chai / Sinon / Mocha configuration.
Expand Down
2 changes: 0 additions & 2 deletions config/karma/karma.conf.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ module.exports = function (config) {
browsers: ["PhantomJS"],
basePath: process.cwd(), // repository root.
files: [
// Sinon has issues with webpack. Do global include.
require.resolve("sinon/pkg/sinon"),
// Test bundle (must be created via `npm run dev|hot|server-test`)
"http://127.0.0.1:8080/assets/bundle.js"
],
Expand Down
2 changes: 0 additions & 2 deletions config/karma/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ module.exports = function (config) {
basePath: process.cwd(),
frameworks: ["mocha", "phantomjs-shim", "intl-shim"],
files: [
// Sinon has issues with webpack. Do global include.
require.resolve("sinon/pkg/sinon"),
MAIN_PATH
],
preprocessors: PREPROCESSORS,
Expand Down
21 changes: 20 additions & 1 deletion config/webpack/webpack.config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ var path = require("path");
var _ = require("lodash");
var prodCfg = require("./webpack.config");

/*
* This prevents webpack from running its
* parsers on any sinon files. Sinon breaks
* when it is `import`ed by a file or module.
* Such as enzyme or your spec files.
* See here:
* https://github.com/webpack/webpack/issues/304
* https://github.com/sinonjs/sinon/pull/600#issuecomment-162529457
*/
prodCfg.module.noParse = [
/node_modules\/sinon\//
];
// Get Paths to give node_modules by resolving based on assumed presence of
// `package.json`.
var _archNodeModules = function (arch) {
Expand All @@ -25,14 +37,21 @@ module.exports = {
resolve: _.merge({}, prodCfg.resolve, {
alias: {
// Allow root import of `src/FOO` from ROOT/src.
src: path.join(process.cwd(), "src")
src: path.join(process.cwd(), "src"),
sinon: require.resolve("sinon/pkg/sinon")
},
modulesDirectories: [
"node_modules",
_archNodeModules("@walmart/electrode-archetype-react-component"),
_archNodeModules("@walmart/electrode-archetype-react-component-dev")
]
}),
// Enzyme depends jsdom and cheerio being global to render their DOM.
externals: {
jsdom: "window",
cheerio: "window",
"react/lib/ExecutionEnvironment": true
},
resolveLoader: prodCfg.resolveLoader,
module: prodCfg.module,
devtool: "source-map"
Expand Down

0 comments on commit 89d6ac7

Please sign in to comment.