Skip to content

it() done documentation? #1801

@ryyppy

Description

@ryyppy

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions