Closed kirkbyo closed 3 years ago
@andymatuschak Thank you for pointing me towards the firebaseSupport
helpers, I had no idea those existed and that we were already spinning up the Firebase emulator in CI; neat!
Given that this infrastructure is already in the backend, I decided to move the tests to package/backend/integration
and run them with the backend tests. This comes with a trade off that the tests need to be ran sequentially, --runInBand
. Without this flag, the test become flaky due to running firestoreDatabaseBackend.test.ts
and the integration tests due to firestoreDatabaseBackend.test.ts
wiping the DB after each test (it was very flaky locally).
This works for now, but I suspect the test times might become too slow in the future, so at that point we could break out the integration tests into its own package and maybe store the firebaseSupport
from within there? Not sure. Let me know if you have any issues with this approach!
@andymatuschak I was a bit surprised as well, I expected some odd compilation errors, but it works locally on my end and it ran successfully in CI. I suspect it has something todo with the Babel config ignoring the included sources defined in the tsconfig
. Not sure 🤔.
I will go ahead and merge and if we run into any issues, I will move the files into backend/src
Added
packages/api-integration
. It holds the full-stack tests of the backend. For now, this package will only run locally since the tests require an instance of the backend (including Firestore) to be running. We could also put these tests in thebackend
package, but I figured a separate package would be easier to configure how we want the tests to run (or not to run in the case of CI).I only created basic test cases for the
/actionLogs
route in this PR, but I will add more if you agree with this approach!Note: I included a few API validation tests in this PR. Although this portion of the code is handled by
Ajv
, I see these tests as a contract to ensure no regressions down the line (instead of testing the internalAjv
). However, I could also see why we wouldn't want to pollute the code with validation tests, so let me know if you have any preferences!