Skip to content

Suggest new assertions on async rejection #507

Description

@3cp

Following up #472 (comment)

Suggest to add the two assertions (or something similar) from tape-promise https://github.com/jprichardson/tape-promise#new-assertions

It would not change the existing behaviour, as the two assertions are async.

Example from tape-promise:

test('reject and doesNotReject example', async (t) => {
  await t.rejects(asyncFunction)
  await t.rejects(asyncFunction())
  await t.doesNotReject(Promise.resolve())
})

The await is on the assertion, not on the input of the assertion. It reads "The input promise will eventually reject".

Right now I am using following code to migrate from tape-promise to tape v5.

test('...', async t => {

  try {
    await something();
    t.fail('should not pass');
  } catch (err) {
    t.ok(err instanceof SomeErrorType);
  }
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions