Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export JestAssertionError from expect #15488

Open
paul23-git opened this issue Feb 4, 2025 · 1 comment
Open

export JestAssertionError from expect #15488

paul23-git opened this issue Feb 4, 2025 · 1 comment

Comments

@paul23-git
Copy link

🚀 Feature Proposal

export JestAssertionError from expect to allow other packages to import it. This is a clone of #9919 as it's still relevant I think?

Motivation

Given that the expect package is modular and published as a standalone package on npm, I'm using it outside of jest and outside of tests. I'm currently trying to use it for implementing a custom mock server for a dev environment. To properly implement this, I need to distinguish expect exceptions from other exceptions, and thus need to do

if (err instanceof JestAssertionError) {}
However this is not currently possible seen as I can't import JestAssertionError from expect

Example

if (err instanceof JestAssertionError) {
  res.status(400).end()
} else {
  res.status(500).end()
}

Example

It can't come from anywhere else

Pitch

It can't come from anywhere else

Copy link

github-actions bot commented Mar 6, 2025

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant