Skip to content

Commit

Permalink
docs: mention about optional done argument in test fn (jestjs#4556)
Browse files Browse the repository at this point in the history
* docs(testAPI): mention about optional `done` argument

I've run into an issue that my test hangs because I've defined the parameter for the test callback. Could be handy to mention that.

* Update GlobalAPI.md
  • Loading branch information
jukben authored and tabrindle committed Oct 2, 2017
1 parent 4d3eb3c commit 73d3532
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/en/GlobalAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ test('did not rain', () => {

The first argument is the test name; the second argument is a function that contains the expectations to test.

If a promise is returned from `test`, Jest will wait for the promise to resolve before letting the test complete.
> Note: If a **promise is returned** from `test`, Jest will wait for the promise to resolve before letting the test complete.
Jest will also wait if you **provide an argument to the test function**, usually called `done`. This could be handy when you want to test callbacks. See how to test async code [here](http://facebook.github.io/jest/docs/en/asynchronous.html#callbacks).

For example, let's say `fetchBeverageList()` returns a promise that is supposed to resolve to a list that has `lemon` in it. You can test this with:

Expand Down

0 comments on commit 73d3532

Please sign in to comment.