summaryrefslogtreecommitdiff
path: root/test/playwright/visual.spec.js
diff options
context:
space:
mode:
authorDarius Jahandarie <djahandarie@gmail.com>2023-11-02 13:09:40 +0000
committerGitHub <noreply@github.com>2023-11-02 13:09:40 +0000
commitcaccc2feb6fdfd271e89b3f0a9a3f9c1cf5ff012 (patch)
tree0397ee020cddc4cec060a04dfcddc0ae45d07a87 /test/playwright/visual.spec.js
parent092d1beac6c1af8eae8615d541434513e875b4a5 (diff)
parent193437fed0f4ee756fd62902947afce54f54dfe6 (diff)
Merge pull request #299 from jbukl/pw-search-anki
search.html clipboard monitor, Anki add note Playwright tests
Diffstat (limited to 'test/playwright/visual.spec.js')
-rw-r--r--test/playwright/visual.spec.js38
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