Skip to content

Instantly share code, notes, and snippets.

@boneskull
Created June 27, 2016 06:20
Show Gist options
  • Save boneskull/eef8c05c4227a5829a3fa2ab9cdbebc4 to your computer and use it in GitHub Desktop.
Save boneskull/eef8c05c4227a5829a3fa2ab9cdbebc4 to your computer and use it in GitHub Desktop.
canonical example of babel (es2015) and Mocha with source map support
export default function foo (str = 'bar') {
if (str === 'baz') {
throw new Error('baz is not allowed');
}
return str;
}
import foo from '.';
import {ok} from 'assert';
describe('foo()', () => {
it('should return "baz" (which should fail)', () => {
ok(foo() === 'baz');
});
it('should print a valid stack trace', () => {
foo('baz');
});
});
{
"name": "mocha-sourcemaps",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha --require source-map-support --require babel-register index.spec.js"
},
"keywords": [],
"author": "Christopher Hiller <[email protected]> (https://boneskull.com/)",
"license": "ISC",
"dependencies": {
"babel-preset-es2015": "^6.9.0",
"babel-register": "^6.9.0",
"mocha": "^2.5.3",
"source-map-support": "^0.4.0"
},
"babel": {
"presets": [
"es2015"
]
}
}
@thmsobrmlr
Copy link

@boneskull Thanks for the example. Here is what I get when using markdown reporter with a passing test: https://gist.github.com/thomas88/6cae8efc5795bd6e60f469d9bf84b692.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment