You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 17, 2019. It is now read-only.
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.
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.test()exported from this package to behave like Jest'stest()global. And it should! Internally Fusion'stest()is just a thin wrapper around Jest'sit(). However,testis missing useful helpers liketest.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.mockFunctionexport which is just a wrapper aroundjest.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.matchSnapshotseems 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:
testexport and theassertcallback – embrace Jest'stest,expectandtoMatchSnapshot.mockFunctionand encourage users to usejest.fn().