Open schnerd opened 5 years ago
+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.
+1000! I can't stress about how many times I came across this problem when writing tests.
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.
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,test
is 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.mockFunction
export 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.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:
test
export and theassert
callback – embrace Jest'stest
,expect
andtoMatchSnapshot
.mockFunction
and encourage users to usejest.fn()
.