jest-matcher-specific-error
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

jest-matcher-specific-error

Make sure your function really throws what you expect

Workaround for https://github.com/facebook/jest/issues/8140

Installation

With npm:

npm install --save-dev jest-matcher-specific-error

With yarn:

yarn add -D jest-matcher-specific-error

Setup

Same as Other jest matchers

Usage

await expect(yourPromise).rejects.toMatchError(expectedError);
await expect(yourFunction).rejects.toMatchError(expectedError);
expect(yourError).toMatchError(expectedError);

Match logic

Errors threated as equal if ALL conditions satisfied:

  • Errors are instances of same class (strict === comparison by reference)
  • Error messages are equal
  • All error public fields are deeply equal (default jest helper comparison)

Error stack traces are ignored.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.08,919latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.08,919
0.0.80
0.0.70
0.0.610
0.0.50
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i jest-matcher-specific-error

Weekly Downloads

7,538

Version

1.0.0

License

MIT

Unpacked Size

5.46 kB

Total Files

6

Last publish

Collaborators

  • daniel.hreben
  • koterpillar