Jest: Inconsistency in the docs and the examples

Created on 9 Apr 2017  ·  3Comments  ·  Source: facebook/jest

PR #3172 updated the docs to include the new .resolves and .rejects keywords for running assertions on Promises.

I noticed that this PR introduced some inconsistencies in the updated Error Handling section of https://github.com/facebook/jest/blob/master/docs/TutorialAsync.md. There is a screenshot of this section below:

screen shot 2017-04-09 at 09 11 46

  1. The comments at the top of the test still refer to try-catch, this is inconsistent with the code contained in the code snippets.
  2. The PR only shows an example with .rejects which will only be available in Jest 20+. This should be mentioned in the docs to avoid confusion.
  3. People using older versions of Jest will not be able to use this documentation. I think we should add back the explanation about using try-catch to catch Promise rejection (that was removed in PR #3172) for people using Jest 19 and below. This can live alongside the current docs using .rejects.
  4. The example contained in the link examples/async links to testing examples like this. These examples still use the try-catch mechanism, this is inconsistent with the code examples currently contained in the docs. This is another reasons why we should add back the explanation of using try-catch to this section of the docs.

Most helpful comment

I am not sure when jest 20 will be released but I hope soon:)

All 3 comments

Is it possible to try out jest 20.0.0+ for those new keywords?

I am not sure when jest 20 will be released but I hope soon:)

I think this is now resolved with #3201. If you think there is more we can do here, please send a PR :)

Was this page helpful?
0 / 5 - 0 ratings