Skip to content
Permalink
Browse files

Add section about ES6 arrow functions

  • Loading branch information...
michielbdejong authored and Michiel de Jong committed Sep 10, 2015
1 parent adf5afa commit 2a91194f74ba09a4cf345b6accce2abac91b473a
Showing with 5 additions and 0 deletions.
  1. +5 −0 index.md
@@ -49,6 +49,7 @@ Mocha is a feature-rich JavaScript test framework running on [Node.js](http://no
- [Assertions](#assertions)
- [Synchronous Code](#synchronous-code)
- [Asynchronous Code](#asynchronous-code)
- [Arrow Functions](#arrow-functions)
- [Hooks](#hooks)
- [Pending Tests](#pending-tests)
- [Exclusive Tests](#exclusive-tests)
@@ -187,6 +188,10 @@ describe('#find()', function() {

(The latter example uses [Chai as Promised](https://www.npmjs.com/package/chai-as-promised) for fluent promise assertions.)

## Arrow functions

Passing [arrow functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) to Mocha is discouraged. Their lexical binding of the `this` value makes them unable to access the Mocha context, and statements like `this.timeout(1000);` will not work inside an arrow function.

## Hooks

Mocha provides the hooks `before()`, `after()`, `beforeEach()`, and `afterEach()`, which can be used to set up preconditions and clean up after your tests.

0 comments on commit 2a91194

Please sign in to comment.
You can’t perform that action at this time.