react-redux-firebase icon indicating copy to clipboard operation
react-redux-firebase copied to clipboard

feat(example): testing a component with useFirestoreConnect

Open prescottprue opened this issue 4 years ago • 5 comments

Do you want to request a feature or report a bug?

  • an example of how to test a component that is using hooks such as useFirestoreConnect as mentioned in #114

prescottprue avatar Mar 03 '20 00:03 prescottprue

hey @prescottprue I add an example on how to use it in this gist: https://gist.github.com/StanSarr/6ef363403793456686b96d0aaa893f65 I'm gonna create a PR If there is none yet :-)

StanSarr avatar Mar 08 '20 18:03 StanSarr

@StanSarr a PR would be great! Thanks for sharing

prescottprue avatar Mar 13 '20 14:03 prescottprue

Any update on this? I checked out @StanSarr's gist it doesn't seem to show testing.

oliver-ni avatar May 14 '20 23:05 oliver-ni

@prescottprue the lack of testing examples has been an ongoing issue for over 3 years (#114). As the author of this library I think you would be best suited to writing an example detailing best practices when testing.

I greatly appreciate the work you have put into this library.

alexandermckay avatar Aug 13 '20 05:08 alexandermckay

As noted in this post testing can be done through mocks if you would like to write component tests.

Personally I have found more integration style tests to be most helpful in a production environment and easiest to maintain - to do that approach you would write tests which actually use the Firebase emulators. This can be done at the component testing level, but can also be done at the UI level with tools like Cypress. Moving things to this level of testing make it much easier to switch the internal logic of your application without having your tests break.

If you go the Cypress route, you may find cypress-firebase helpful to simplify that interaction - here are some examples:

prescottprue avatar Aug 19 '20 01:08 prescottprue