Skip to content

Rule proposal: prefer-t-throws #156

Open
@gajus

Description

@gajus

Issuehunt badges

I was reviewing some codes using ava and found this pattern repeating often:

try {
  await request(requestOptions);
} catch (error) {
  t.true(error.statusCode === 500);
}

This can be written instead as:

const error = await t.throws(request(requestOptions));

t.true(error.statusCode === 500);

I think the latter should be preferred.


IssueHunt Summary

Backers (Total: $80.00)

Submitted pull Requests


Become a backer now!

Or submit a pull request to get the deposits!

Tips

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