glennsl/rescript-jest

Support for end-to-end tests...

alltonp opened this issue · 3 comments

Hi,

Firstly, I've just found bs-jest, I've just started using it for unit tests and its great, so thank you for that. The problem is now I'd really like to use it for end-to-end tests...

Some background:

  • I've got a Reason React Native mobile app with some end-to-end tests written in detox, which is working really nicely.
  • Detox tests currently have to be written in javascript and I'd obviously much rather write them in reasonml.

Detox uses jest under the hood and I'm thinking it would be awesome if there was a way to write Detox tests in bs-jest.

I am mindful of bs-jest's stance of one assertion per test, which I completely agree with for unit tests, but in my experience end-to-end tests are always going to be more imperative by nature (i.e. type some things in, click a button, assert some things, do the next thing, assert some more things etc).

I'm wondering if you think there might be away to integrate the two, or perhaps have some way to extend bs-jest to support Detox?

Many thanks,
Paul

Hi. I think the bigger problem here might be the heavy use of promises, which isn't very elegantly handle in BuckleScript/rescript as of yet. It might be possible to offer a set of primitives that handle both the promises and multiple assertions more elegantly, but I think it's still going to be a bit clunky and I'm not sure using Reason instead of JavaScript would be worth it just because of that.

As I haven't used BuckleScript/rescript for years I'm not likely to spend much time looking into or working on this myself, but I'm certainly open for proposals along these lines.

I managed to get something working and integrating with bs-jest, yes the promises were a PITA but for me it's still better than having to write javascript in my reason codebase.

Closing this out, but for anyone interested, take a look at reason-detox

With the PPX that looks pretty nice to me. Good job!