Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Reduce API opaque-ness and embrace Jest #189

Open
schnerd opened this issue Dec 3, 2018 · 3 comments
Open

Reduce API opaque-ness and embrace Jest #189

schnerd opened this issue Dec 3, 2018 · 3 comments

Comments

@schnerd
Copy link

schnerd commented Dec 3, 2018

The fusion test environment heavily leverages Jest, which is great. However it does so in a way which is opaque to developers and leads to confusion.

Most developers know that fusion is using Jest internally. So they end up using other useful Jest globals like describe(), beforeAll() etc.

  • With that in mind, it makes sense that they'd expect the test() exported from this package to behave like Jest's test() global. And it should! Internally Fusion's test() is just a thin wrapper around Jest's it(). However, test is missing useful helpers like test.only, test.skip, etc. I just sat with a developer who was trying to use these for 10-15 minutes, only to realize they don't exist on fusion's wrapper implementation.
  • There's also the mockFunction export which is just a wrapper around jest.fn() without any extra logic. The documentation for mockFunction in README.md is super short and doesn't describe anywhere near the amount of behavior that jest.fn() is capable of.
  • assert.matchSnapshot seems to be another unnecessary wrapper around jests matchSnapshot functionality.

It's possible that some of these decisions may have been made in the spirit of trying to keep the Jest dependency hidden in case we want to switch to something else in the future. But I think this ship has sailed considering engineers are already leveraging other jest globals like describe/beforeEach/etc, and mockFunction just returns a jest.fn anyway with all it associated behavior in tact.

In the spirit of turning this into a more concrete request, I'm hoping we can:

  • Get rid of Fusion's test export and the assert callback – embrace Jest's test, expect and toMatchSnapshot.
  • Get rid of mockFunction and encourage users to use jest.fn().
  • Moving forward, more clearly call out in documentation that the full Jest environment is available in tests, and link out to Jest docs where appropriate.
@sravanti
Copy link

sravanti commented Dec 3, 2018

+1 for using Jest's test and expect — in the documentation, the use of assert and expect are inconsistent, which can be confusing to newcomers. Also agreed with linking out to Jest docs, as I didn't really understand that I should be referencing Jest docs in addition to the Fusion test util docs.

@manassra
Copy link

manassra commented Dec 3, 2018

+1000! I can't stress about how many times I came across this problem when writing tests.

@mlmorg
Copy link

mlmorg commented Apr 3, 2019

Sorry for the delay on responding to this on Github. We plan to remove the wrapper and expose Jest directly. We hope to tackle this in the next month or so.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants