Open DoubleJ-G opened 1 month ago
constructor is designed to be private in order to enforce usage via .from
factory function.
Probably nothing can be done except type casting at the moment. I was not aware about this limitation. I’ll take a look a bit later and very likely just will make it public
Is your feature request related to a problem? Please describe.
I want to be able to test that a function throws a ForbiddenError. Take this snippet for example:
Currently this is not possible due to the private constructor jest will complain with the following.
Describe alternatives you've considered (optional) You can test that the function throws any error with
.toThrow()
but this isn't precise. In the example above it's the only thing that can throw but in other places I have multiple things to throw and only want to test for ForbiddenError in some testsIs there a reason for the constructor of this Error to be private? Or is there any alternative to testing that the function throws this type of error?