Skip to content

Commit

Permalink
docs: clarify invalid usage of done() (mochajs#4101)
Browse files Browse the repository at this point in the history
When I first read 
"anything else will cause a failed test"
I considered that this might be a typo,
and that this should say "a passed test"
instead, because after all setting "no error"
could mean "no error", right? I then understood
that this sentence could also mean that
"anything else is a programmer error", i.e. a bug
and I was hoping that in _that_ case a clear
error would be thrown.

I tried things out and indeed found that the latter
is the case

> Error: done() invoked with non-Error: true

This patch attempts to clarify that this is
indeed all about a programmer error.
  • Loading branch information
jgehrcke authored and craigtaub committed Nov 23, 2019
1 parent 2e9c28a commit ebdee97
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ Mocha allows you to use any assertion library you wish. In the above example, we

## 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` instance (or subclass thereof) _or_ a falsy value; anything else 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 is invalid usage and throws an error (usually causing a failed test).

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

0 comments on commit ebdee97

Please sign in to comment.