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:
@@ -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)
|
||||
|
||||
16
javascript/running-es6-specs-with-mocha.md
Normal file
16
javascript/running-es6-specs-with-mocha.md
Normal 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/)
|
||||
Reference in New Issue
Block a user