const { expect } = require('@playwright/test');

const startSelector = '#start';
const resultSelector = '#testResult';
const logError = (page, msg) => {
  const title = await page.title();
  // eslint-disable-next-line no-console
  console.error(title, msg);
}

// default timeout = // 10mins
module.exports = async (page, timeout = 10 * 60 * 2000) => {
  
  page.on('pageerror', (err) => {
    logError(page, err.message);
  });
  page.on('console', (msg) => {
    if (msg.type() === 'error') {
      logError(page, msg.text());
    }
  });

  await page.waitForLoadState('domcontentloaded', { timeout: 5000 });
  await page.click(startSelector, { timeout: 1000 });

  await page.locator(resultSelector).waitFor({ state: 'visible', timeout });
  await expect(page.locator(resultSelector)).toHaveClass('passed', { timeout: 1000 });
};

@@ -128,16 +128,22 @@
 gError =
+ async
  (page, 
@@ -259,16 +259,17 @@
  msg);%0A%7D
+;
 %0A%0A// def
@@ -358,11 +358,8 @@
 %3E %7B%0A
-  %0A
   pa

fix async