Closed DoryZi closed 9 months ago
Good question! For your unit tests, I would consider mocking react-recurly
according to your usage. If you're aiming for more of an integration test, you will likely need to go down the path of introducing a real DOM with an html fixture including the recurly.js
asset.
We use Jest only for atomic unit tests. If you're looking to perform more of an integration test, I think another tool would be better suited.
I see in your unit test there are mocks, I don't mind using those (I would prefer to use the real lib). How can I use those? I mean you guys mock it yourselves, why not expose it ? I would love to use your existing mock than re-invest the wheel? Is that possible?
We mock some underlying dependencies, but don't have a mock implementation that would cover all of react-recurly
for use in tests that depend on react-recurly
. So my recommendation is that in your test suite, wherever you might invoke react-recurly
, to mock those specific invocations.
yes but it asks for recurly.js dependecy .. :/
+1, same problem in my case, useRecurly
in components make it very hard to test
not sure how to begin mocking this
I concur, a better way to mock useRecurly would be greatly appreciated.
was it completed?
I'm using React Recurly, it's great stuff :) However in order to run unit tests (jest, react testing library), I must put the script in the html. Jest doesn't seem to offer a simple way to do that, and including the file hosted, doesn't seem to work well either.
How do you suggest someone using recurly.js build unit tests that use the react recurly? Is there a recommended or suggested path for including a js from cdn in jest ?
Please assist this is a blocker for me. Thanks! D.