From ccddce5546e99c409ee786d0a7ae7a6fc6e0b52e Mon Sep 17 00:00:00 2001 From: Marais Rossouw Date: Thu, 4 Jan 2018 12:16:17 +1000 Subject: [PATCH 1/2] docs: Error/undefined params to the 'done' callback --- docs/index.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/index.md b/docs/index.md index 55256df65b..d5fa2494ac 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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` (or subclassed) instance, or `undefined`, any non-falsy will cause a failed test. ```js describe('User', function() { @@ -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 (ie, `new Error()`), so we may use this directly: ```js describe('User', function() { @@ -1301,4 +1301,3 @@ $ REPORTER=nyan npm test ## More Information In addition to chatting with us on [Gitter](https://gitter.im/mochajs/mocha), for additional information such as using spies, mocking, and shared behaviours be sure to check out the [Mocha Wiki](https://github.com/mochajs/mocha/wiki) on GitHub. For discussions join the [Google Group](https://groups.google.com/group/mochajs). For a running example of Mocha, view [example/tests.html](example/tests.html). For the JavaScript API, view the [source](https://github.com/mochajs/mocha/blob/master/lib/mocha.js#L51). - From 5e1cacf59ced90d030fa396f290bddf76febd800 Mon Sep 17 00:00:00 2001 From: Marais Rossouw Date: Fri, 5 Jan 2018 11:32:48 +1000 Subject: [PATCH 2/2] chore: fixed up some code review missups --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index d5fa2494ac..394bc5a5bb 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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. This callback accepts both an `Error` (or subclassed) instance, or `undefined`, any non-falsy will cause a failed 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() { @@ -171,7 +171,7 @@ describe('User', function() { }); ``` -To make things even easier, the `done()` callback also accepts an `Error` instance (ie, `new 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() {