rescript-jest
rescript-jest copied to clipboard
Is Expect extensible?
Hello, thanks for the bindings!
I've looked into the code and as far as I can see, the Expect module creates jest assertions via assertion variant. This makes the API clean, but doesn't really allow users to introduce custom matchers. E.g. we use jest-dom and testing-library/jest-native and we weren't been able to properly cooperate the custom matchers with Expect module.
Hello, thanks for the bindings! I've looked into the code and as far as I can see, the
Expectmodule creates jest assertions viaassertionvariant. This makes the API clean, but doesn't really allow users to introduce custom matchers. E.g. we use jest-dom and testing-library/jest-native and we weren't been able to properly cooperate the custom matchers withExpectmodule.
Same problem here. I had to vendor this library and add the extra needed matchers. Would love to know if the author recommends a solution better than forking the library and adding the matchers. Anyways thanks for this work.
It should be possible to create a custom asserter and awkwardly re-exposing and forwarding the original assertions to the default asserter. But it wasn't really designed for extensibility, even if that's long been desired. It would likely require a complete rewrite of the internals, and I don't have time to do that. But I would certainly welcome efforts to do so while at the very least retaining the design philosophy, if not the API.