Skip to content

Commit

Permalink
document Error/undefined params to the 'done' callback; closes #3134
Browse files Browse the repository at this point in the history
* docs: Error/undefined params to the 'done' callback
  • Loading branch information
maraisr authored and boneskull committed Jan 9, 2018
1 parent b2697a7 commit cb09e8b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/index.md
Expand Up @@ -155,7 +155,7 @@ Mocha allows you to use any assertion library you wish. In the above example, w

## Asynchronous Code

Testing asynchronous code with Mocha could not be simpler! Simply invoke the callback when your test is complete. By adding a callback (usually named `done`) to `it()`, Mocha will know that it should wait for this function to be called to complete the test.
Testing asynchronous code with Mocha could not be simpler! Simply invoke the callback when your test is complete. By adding a callback (usually named `done`) to `it()`, Mocha will know that it should wait for this function to be called to complete the test. This callback accepts both an `Error` instance (or subclass thereof) *or* a falsy value; anything else will cause a failed test.

```js
describe('User', function() {
Expand All @@ -171,7 +171,7 @@ describe('User', function() {
});
```

To make things even easier, the `done()` callback accepts an error, so we may use this directly:
To make things even easier, the `done()` callback also accepts an `Error` instance (i.e. `new Error()`), so we may use this directly:

```js
describe('User', function() {
Expand Down

0 comments on commit cb09e8b

Please sign in to comment.