-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Document]: Error/undefined params to the 'done' callback #3192
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Added some clarification
docs/index.md
Outdated
@@ -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 `undefined`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3134 isn't quite accurate about what needs to be documented.
We need to document that any non-falsy, non-Error
instance passed into done()
will cause Mocha to fail.
Subclasses of Error
are allowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check if that is accurate?
docs/index.md
Outdated
@@ -184,6 +184,7 @@ describe('User', function() { | |||
}); | |||
``` | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove
@boneskull do you think we can get this merged? Kinda excited to have committed something that was merged into Mocha. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for updating this. I have a couple more issues, if you don't mind?
docs/index.md
Outdated
@@ -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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be i.e.
not ie
docs/index.md
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, let's just eliminate undefined
altogether here. it's also a bit of a run-on sentence. how about:
This callback accepts both an `Error` instance (or subclass thereof) *or* a falsy value; anything else will cause a failed test.
thanks! |
Resolves: #3134