diff options
Diffstat (limited to 'test/playwright/visual.spec.js')
| -rw-r--r-- | test/playwright/visual.spec.js | 38 | 
1 files changed, 9 insertions, 29 deletions
| diff --git a/test/playwright/visual.spec.js b/test/playwright/visual.spec.js index acb12e97..001f329f 100644 --- a/test/playwright/visual.spec.js +++ b/test/playwright/visual.spec.js @@ -16,40 +16,20 @@   */  const path = require('path'); -const {test: base, chromium} = require('@playwright/test'); -const root = path.join(__dirname, '..', '..'); - -export const test = base.extend({ -    context: async ({ }, use) => { -        const pathToExtension = path.join(root, 'ext'); -        const context = await chromium.launchPersistentContext('', { -            // headless: false, -            args: [ -                '--headless=new', -                `--disable-extensions-except=${pathToExtension}`, -                `--load-extension=${pathToExtension}` -            ] -        }); -        await use(context); -        await context.close(); -    }, -    extensionId: async ({context}, use) => { -        let [background] = context.serviceWorkers(); -        if (!background) { -            background = await context.waitForEvent('serviceworker'); -        } -        const extensionId = background.url().split('/')[2]; -        await use(extensionId); -    } -}); -const expect = test.expect; +const { +    test, +    expect, +    root +} = require('./playwright-util'); -test('visual', async ({context, page, extensionId}) => { +test.beforeEach(async ({context}) => {      // wait for the on-install welcome.html tab to load, which becomes the foreground tab      const welcome = await context.waitForEvent('page');      welcome.close(); // close the welcome tab so our main tab becomes the foreground tab -- otherwise, the screenshot can hang +}); +test('visual', async ({page, extensionId}) => {      // open settings      await page.goto(`chrome-extension://${extensionId}/settings.html`); @@ -117,4 +97,4 @@ test('visual', async ({context, page, extensionId}) => {          await screenshot(2, i, el, {x: 15, y: 15});          i++;      } -}); +});
\ No newline at end of file |