chore: Improve racy tests #769
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This started out as updating the
should not report fetching statusWeb Watched query test - then it progressed some some general Node.js test stability improvements. The changes here should increase the stability of tests, but I don't believe they are 100% stable yet.For
should not report fetching status: That tests was inherently flawed. ThepowerSync.query(...).watch(...)API requires a comparator option in order to limit result emissions. We didn't supply one, so it's a wonder that test passed at all.For Node.js: The main change there is to use a separate db for each
mockSyncServiceTest. I found at least one test where the CRUD upload lock was held by another test which timed another test out. Separating the tests should increase their stability.The mocked sync service uses the HTTP
fetchmethod to create a manually controlled stream. I found numerous Stream ReaderThe reader is not attached to a streamerror logs between tests. I believe this log probaby caused a retry delay which timed tests out. Some minor improvements to the closing of HTTP streams have been implemented in AbstractRemote to mitigate this.Some of the log interceptor tests were also failing due to not detecting certain log messages. I'm not sure how these tests passed in the current code-base since the intercepted logger was not passed to the PowerSync database constructor.