({ recordVideo, workspacePath }: { recordVideo?: boolean; workspacePath?: string } = {})
| 285 | } |
| 286 | |
| 287 | async getOrCreateApplication({ recordVideo, workspacePath }: { recordVideo?: boolean; workspacePath?: string } = {}): Promise<Application> { |
| 288 | if (this._closing) { |
| 289 | await this._closing; |
| 290 | } |
| 291 | if (!this._application) { |
| 292 | this._application = await getApplication({ recordVideo, workspacePath }); |
| 293 | this._application.code.driver.currentPage.on('close', () => { |
| 294 | this._closing = (async () => { |
| 295 | if (this._application) { |
| 296 | this._application.code.driver.browserContext.removeAllListeners(); |
| 297 | await this._application.stop(); |
| 298 | this._application = undefined; |
| 299 | await this._runAllListeners(); |
| 300 | } |
| 301 | })(); |
| 302 | }); |
| 303 | await this._runAllListeners(); |
| 304 | } |
| 305 | return this._application; |
| 306 | } |
| 307 | |
| 308 | private async _runAllListeners() { |
| 309 | for (const listener of this._listeners) { |
no test coverage detected