Skip to content
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

it() done documentation? #1801

Closed
ryyppy opened this issue Sep 26, 2016 · 3 comments
Closed

it() done documentation? #1801

ryyppy opened this issue Sep 26, 2016 · 3 comments

Comments

@ryyppy
Copy link

ryyppy commented Sep 26, 2016

Hi!

Today I was in a dire need of a fail() function to fail my tests and after looking through documentation and examples, I remembered there was this it('', (done) => {...}) thing, in a time where Promises were not yet popular :-)

I realized that done is not only a function, but also has a done.fail(), which is super valuable for cases like

try {
  await fnWhichShouldFail();
  done.fail();
} catch(e) {
  expect(e.message).toBe('some failure');
}

For async function flows or chained promises with a catch, I didn't find a clean way to prevent undetected errors for erroneous testing code (if I hadn't had the done.fail() in the example above, a test would run through green, if fnWhichShouldFail() was mocked wrongly and doesn't throw.

So my question is: Is there any reason why there is no documentation about that? Or do you have plans for a better API replacement?

@0xR
Copy link
Contributor

0xR commented Sep 26, 2016

Note jest uses jasmine and the jasmine docs say this: https://jasmine.github.io/2.5/introduction.html#section-58

@cpojer
Copy link
Member

cpojer commented Sep 29, 2016

Yeah, for now we rely on the Jasmine docs for this. We'll document it at some point when we have something new. If you'd like to document the done syntax on the Jest website, please send us a PR :)

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants