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
feat(testing): explicit resource management for spy()
and stub()
#4306
Conversation
Note to self: run CI when the required functionality is available in canary. Tests should pass in canary but fail in stable. |
I didn't notice, but this is already the case! 😆 We've already upgraded to |
@KyleJune, would you also like to update any applicable spies and stubs across the codebase to use the |
I think we should also add a note about the minimum Deno version required for it to work. 👍 |
Done, the only ones outside of the context of testing
I don't think that is necessary and that wasn't done when |
I think this PR is now ready to be reviewed as Deno v1.40.5 supports |
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. Looks a nice feature!
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.
This is awesome. Thank you! LGTM.
spy()
and stub()
spy()
and stub()
Closes #3966
This is a work in progress. It won't work until swc is upgraded to v1.4.0 because earlier versions do not support the
using
keyword on functions. Until that issue is resolved, the new test cases I added fail with the following errors.Once that issue is resolved, I believe the new test cases in this PR will pass and we could go forward with shipping it.
Regarding documentation, I added a description to both the spy and stub sections to explain that they are disposable. I noticed that FakeTime was already made disposible and it's example uses the
using
keyword. I thought it would be better to explicitly explain that sinceusing
is a new feature to TypeScript. I think if all the examples were updated to just use theusing
keyword to automate cleanup, people could easily miss the importance of that keyword in ensuring that the tests are cleaned up properly. Feel free to change my descriptions though.