snippets-web icon indicating copy to clipboard operation
snippets-web copied to clipboard

Unclear that tests actually validate their results?

Open gregfenton opened this issue 2 years ago • 3 comments

https://github.com/firebase/snippets-web/blob/c5bfca32e881d7a40002285384a784749f973c35/firestore/test.solution-counters.js#L49

In the test group that starts at the above line, it isn't clear to me that the results of the tests are actually being tested? What validates that the counters are created? What validates that the incremented value is correct?

gregfenton avatar Aug 15 '21 19:08 gregfenton

@gregfenton most of the tests here are only to ensure that the code is syntactically valid and doesn't throw immediate exceptions. We don't test that they produce the intended backend result, although if you want to submit a PR to improve any of the tests to be more meaningful we'd be happy to review!

samtstern avatar Aug 16 '21 13:08 samtstern

My main concern is that this snippet is highlighted in the documentation as the source for the Distributed Counters pattern. But these tests do not show how to use the pattern. So we are left to figure things out on our own?

I'm currently struggling with this: https://github.com/gregfenton/example-firestore-distributed-counter

gregfenton avatar Aug 16 '21 14:08 gregfenton

@gregfenton totally fair! I'm actually no longer on the Firebase team so cc @morganchen12 and @abeisgoat who may want to take a look here.

samtstern avatar Aug 19 '21 14:08 samtstern