Dev Log: Nov 15, 2016
Originally published on Medium.
WebStorm: Running Specific Tests with Mocha + Babel
Running tests from the terminal involved too many keystrokes. The team is using ES2015 with Mocha, but running tests through WebStorm failed because it didn’t recognise the syntax. Fix:
- Press
⌘⇧Aand search for “Select Run/Debug Configuration” - Click Edit configurations
- Under Defaults → Mocha, add to the extra Mocha options field:
--compilers js:babel-core/register - Apply
Now you can:
- Position your cursor inside any
describeoritblock and pressCtrl⇧Rto run just that test - Press
Ctrl Rto rerun the last test
Much faster feedback loop.
IE11 Compatibility View Issue
Modern JS frameworks often don’t support IE compatibility mode even when IE11 itself is the target. If users have compatibility mode enabled for legacy sites, it can silently break your app. Fix — add this to your HTML <head>:
<meta http-equiv="X-UA-Compatible" content="IE=edge;" />Forces IE to use its highest available rendering mode regardless of compatibility settings.
Redux and IE11: Two Missing Pieces
1. Object.assign Not Supported
Redux patterns rely on Object.assign for immutable state updates, which IE11 doesn’t support natively. Install the Babel plugin:
npm install --save babel-plugin-transform-object-assignUpdate .babelrc:
{
"presets": ["es2015", "react"],
"plugins": ["transform-object-assign"]
}2. Promises Not Supported
IE11 has no native Promise support. Fix with babel-polyfill:
npm install --save babel-polyfillUpdate your webpack.config.js entry point to include the polyfill before your app:
var config = {
entry: ['babel-polyfill', APP_DIR + '/App.jsx'],
// ...
}Both of these are easy to miss until you test in IE and everything silently breaks.