-
Notifications
You must be signed in to change notification settings - Fork 945
Adding call to clearPersistence() into AsyncQueue #1740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
await expect(clearPersistence(firestore)).to.eventually.be.rejectedWith( | ||
'Failed to delete the database.' | ||
); | ||
SimpleDb.delete = oldDelete; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should pull this out of the withTestDoc block so that you can put it in a finally block
const oldDelete = SimpleDb.delete;
try {
// monkey patch and test
} finally {
SimpleDb.delete = oldDelete
}
This form is desirable because it prevents a failure in this test from causing unrelated failures in subsequent tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with taking the patch out of withTestDoc
is that withTestDoc
eventually ends up calling withTestDbsSettings
, which clears persistence at the end of the the function. Not restoring SimpleDb.delete
to its original definition causes those tests to fail when the test is torn down:
(Persistence=true) Database
✗ will reject the promise if clear persistence fails
Error: the string "Failed to delete the database :(." was thrown, throw an Error :)
HeadlessChrome 74.0.3729 (Mac OS X 10.14.4) (Persistence=true) Database will reject the promise if clear persistence fails FAILED
Error: the string "Failed to delete the database :(." was thrown, throw an Error :)
What do you think about resetting SimpleDb.delete
twice just to be safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not do the try/finally inside withTestDoc
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once again, thank you. 🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for taking the time to make this right!
No description provided.