diff --git a/README.md b/README.md index 6318584..a1e87af 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ _379 TILs and counting..._ - [Numbers Are Empty](javascript/numbers-are-empty.md) - [Object Initialization With Shorthand Property Names](javascript/object-initialization-with-shorthand-property-names.md) - [Random Cannot Be Seeded](javascript/random-cannot-be-seeded.md) +- [Running ES6 Specs With Mocha](javascript/running-es6-specs-with-mocha.md) - [Splat Arguments To A Function](javascript/splat-arguments-to-a-function.md) - [Throttling A Function Call](javascript/throttling-a-function-call.md) - [Transforming ES6 and JSX With Babel 6](javascript/transforming-es6-and-jsx-with-babel-6.md) diff --git a/javascript/running-es6-specs-with-mocha.md b/javascript/running-es6-specs-with-mocha.md new file mode 100644 index 0000000..e1c7d8e --- /dev/null +++ b/javascript/running-es6-specs-with-mocha.md @@ -0,0 +1,16 @@ +# Running ES6 Specs With Mocha + +If your JavaScript specs contain ES6 syntax, [Mocha](https://mochajs.org/), +by default, will not be able to interpret and run them. In order to run them +with Mocha, you will need to tell Mocha to use something like +[Babel](http://babeljs.io/) to compile them. The `--compile` flag can be +used to point Mocha to the `babel-core/register` package. + +``` +$ mocha --compilers js:babel-core/register path/to/specs/*.spec.js +``` + +If you already have a test command specified in your `package.json` file, +you can update it with the `--compile` portion of the above command. + +[source](http://jamesknelson.com/testing-in-es6-with-mocha-and-babel-6/)