MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / _cleanup

Method _cleanup

lib/helper/Playwright.js:875–902  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

873 }
874
875 async _cleanup() {
876 // Final cleanup when test run completes
877 if (this.isRunning) {
878 try {
879 // Add timeout protection to prevent hanging
880 await Promise.race([this._stopBrowser(), new Promise((_, reject) => setTimeout(() => reject(new Error('Browser stop timeout in cleanup')), 10000))])
881 } catch (e) {
882 console.warn('Warning during final cleanup:', e.message)
883 // Force cleanup on timeout
884 this.browser = null
885 this.browserContext = null
886 this.isRunning = false
887 }
888 } else {
889 // Check if we still have a browser object despite isRunning being false
890 if (this.browser) {
891 try {
892 // Add timeout protection to prevent hanging
893 await Promise.race([this._stopBrowser(), new Promise((_, reject) => setTimeout(() => reject(new Error('Browser stop timeout in forced cleanup')), 10000))])
894 } catch (e) {
895 console.warn('Warning during forced cleanup:', e.message)
896 // Force cleanup on timeout
897 this.browser = null
898 this.browserContext = null
899 }
900 }
901 }
902 }
903
904 _session() {
905 const defaultContext = this.browserContext

Callers 2

helpers.jsFile · 0.80
closeBrowserFunction · 0.80

Calls 1

_stopBrowserMethod · 0.95

Tested by

no test coverage detected