Skip to content

Assertions on error properties #123

@dominykas

Description

@dominykas

Ran into a use case recently, where I'd like to assert on error codes and some more meta information.

I'm thinking about error([type], [message], [values]) / throw([type], [message], [values]), e.g.

expect(() => someMethod()).to.throw(CustomError, 'Oh no!', { code: 'E_NOENT' });

This would essentially do an extra expect(error).to.include(values); - there is no other way to check this when using to.throw() AFAIK?

Happy to PR if acceptable.

Metadata

Metadata

Assignees

Labels

featureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions