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

Reduce API opaque-ness and embrace Jest #189

@schnerd

Description

@schnerd

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions