forked from os-scar/overlay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixtures.js
32 lines (28 loc) · 1.19 KB
/
fixtures.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//This file is needed to use the tests with the extension installed and running
import { test as base, chromium } from '@playwright/test';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export const test = base.extend({
// eslint-disable-next-line no-empty-pattern
context: async ({}, use) => {
const pathToExtension = path.join(__dirname, 'dist', 'chrome');
const context = await chromium.launchPersistentContext('', {
headless: false,
// To run and debug the extension in head mode remove `--headless=new` from args
args: [`--headless=new`, `--disable-extensions-except=${pathToExtension}`, `--load-extension=${pathToExtension}`],
// remove the comment below to slow down the tests
// slowMo: 500
});
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);
},
});
export const Expect = test.expect;