1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add Running ES6 Specs With Mocha as a javascript til

This commit is contained in:
jbranchaud
2016-03-31 15:18:10 -05:00
parent 2d09107602
commit d10386d38a
2 changed files with 17 additions and 0 deletions

View File

@@ -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/)