Skip to content

Commit

Permalink
clean up configs/webpack DefinePlugin; add __TEST__ DefinePlugin to s…
Browse files Browse the repository at this point in the history
…kip stack trace in browser tests
  • Loading branch information
jebeck committed Feb 8, 2016
1 parent 5c55ba8 commit 2bc15a2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .config.js
Expand Up @@ -33,12 +33,13 @@ function stringToArray(str, defaultValue) {
}

module.exports = {
// this is to always have the Bows logger turned on!
// NB: it is distinct from our own "debug mode"
DEBUG: stringToBoolean(process.env.DEBUG, true),
// the defaults for these need to be pointing to prod
API_URL: process.env.API_URL || 'https://api.tidepool.org',
UPLOAD_URL: process.env.UPLOAD_URL || 'https://uploads.tidepool.org',
BLIP_URL: process.env.BLIP_URL || 'https://blip.tidepool.org',
CARELINK: stringToBoolean(process.env.CARELINK, true),
DEFAULT_TIMEZONE: process.env.DEFAULT_TIMEZONE || 'America/Los_Angeles',
DEFAULT_CARELINK_DAYS: process.env.DEFAULT_CARELINK_DAYS || '180'
};
18 changes: 10 additions & 8 deletions lib/redux/actions/async.js
Expand Up @@ -15,7 +15,7 @@
* == BSD2 LICENSE ==
*/

/* global chrome */
/* global chrome, __TEST__ */

import _ from 'lodash';
import async from 'async';
Expand Down Expand Up @@ -213,13 +213,15 @@ function makeUploadCb(dispatch, getState, errCode, utc) {
version: version
};

uploadErrProps.stringifiedStack = _.pluck(
_.filter(
stacktrace.parse(err),
(cs) => { return cs.functionName !== null; }
),
'functionName'
).join(', ');
if (!__TEST__) {
uploadErrProps.stringifiedStack = _.pluck(
_.filter(
stacktrace.parse(err),
(cs) => { return cs.functionName !== null; }
),
'functionName'
).join(', ');
}
return dispatch(syncActions.uploadFailure(displayErr, uploadErrProps, targetDevice));
}
const currentUpload = _.get(uploadsByUser, [uploadTargetUser, targetDevice.key], {});
Expand Down
8 changes: 8 additions & 0 deletions test.config.js
@@ -1,4 +1,9 @@
var path = require('path');
var webpack = require('webpack');

var definePlugin = new webpack.DefinePlugin({
__TEST__: true
});

module.exports = {
module: {
Expand All @@ -15,6 +20,9 @@ module.exports = {
{ test: /\.json$/, loader: 'json' }
]
},
plugins: [
definePlugin
],
// to fix the 'broken by design' issue with npm link-ing modules
resolve: { fallback: path.join(__dirname, 'node_modules') },
resolveLoader: { fallback: path.join(__dirname, 'node_modules') }
Expand Down
11 changes: 3 additions & 8 deletions webpack.config.js
Expand Up @@ -3,7 +3,8 @@ var _ = require('lodash');
var webpack = require('webpack');

var definePlugin = new webpack.DefinePlugin({
__DEBUG__: JSON.stringify(JSON.parse(process.env.DEBUG_ERROR || 'false'))
__DEBUG__: JSON.stringify(JSON.parse(process.env.DEBUG_ERROR || 'false')),
__TEST__: false
});

if (process.env.DEBUG_ERROR === 'true') {
Expand Down Expand Up @@ -38,13 +39,7 @@ var config = {
]
},
plugins: [
definePlugin,
new webpack.DefinePlugin({
'process.env': Object.keys(process.env).reduce(function(o, k) {
o[k] = JSON.stringify(process.env[k]);
return o;
}, {})
})
definePlugin
],
// to fix the 'broken by design' issue with npm link-ing modules
resolve: { fallback: path.join(__dirname, 'node_modules') },
Expand Down

0 comments on commit 2bc15a2

Please sign in to comment.