rescript-jest icon indicating copy to clipboard operation
rescript-jest copied to clipboard

Is Expect extensible?

Open a-gierczak opened this issue 5 years ago • 2 comments

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.

a-gierczak avatar Nov 16 '20 13:11 a-gierczak

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.

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.

leoparis89 avatar May 18 '22 21:05 leoparis89

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.

glennsl avatar May 19 '22 08:05 glennsl