UNPKG

systelab-components-wdio-test

Version:
27 lines (26 loc) 846 B
import { remote } from "webdriverio"; export class ApplicationManager { static async start(browserType, options) { const id = this.nextId; this.nextId += 1; const browser = await remote(options); const application = { id, browserType, options, browser }; this.applications.push(application); return application; } static async stop(id) { const app = this.get(id); if (app) { await app.browser.deleteSession(); this.applications = this.applications.filter(app => app.id !== id); } else { throw new Error(`Application with id ${id} not found`); } } static get(id) { return this.applications.find(app => app.id === id); } } ApplicationManager.nextId = 1; ApplicationManager.applications = [];