If I am not using the context test fixture, but instead browser and calling browser.newContext(), should I close these contexts at the end of the test? Or can they be garbage-collected and closed automatically?
If I need to close them, I'd expect the documentation or examples to say so somewhere but couldn't find it.
Terminology:
If you close the browser, all pages and contexts within the browser are closed too.
Very likely, you're closing the browser after each test (this is the default behavior if you use preset fixtures, keeping tests isolated). In that case, there's no need to close contexts or pages.
But if you're keeping the browser open across tests, and you're creating contexts on a short-term basis, then, yes, close those contexts when they're no longer needed (likely afterEach).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With