Skip to content

Commit

Permalink
update emulator setting and adjust sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
tilfin committed Oct 20, 2023
1 parent 23bd930 commit e4c2d7b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
24 changes: 24 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
projects: [
{
name: 'chrome',
use: {
...devices['Desktop Chrome'],
channel: 'chrome'
},
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'Microsoft Edge',
use: {
...devices['Desktop Edge'],
channel: 'msedge'
},
},
],
});
14 changes: 12 additions & 2 deletions test/emulator/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ const sleep = util.promisify(setTimeout);
export const testInOptions = (message, beforeFunc, pageFunc, afterFunc) => {
test(message, async ({ page, context, extensionId }) => {
const [worker] = context.serviceWorkers();
await sleep(400);

const resultB = await worker.evaluate(beforeFunc);
if (resultB !== undefined) console.log(resultB);

await page.goto(`chrome-extension://${extensionId}/options.html`);
const resultP = await pageFunc({ page, expect: test.expect });
if (resultP !== undefined) console.log(resultP);

await sleep(1000);
await sleep(400);

const resultA = await worker.evaluate(afterFunc);
if (resultA !== undefined) console.log(resultA);
//await sleep(1000000);
Expand All @@ -50,14 +53,17 @@ export const testInOptions = (message, beforeFunc, pageFunc, afterFunc) => {
export const testInPopup = (message, beforeFunc, pageFunc, afterFunc) => {
test(message, async ({ page, context, extensionId }) => {
const [worker] = context.serviceWorkers();
await sleep(400);

const resultB = await worker.evaluate(beforeFunc);
if (resultB !== undefined) console.log(resultB);

await page.goto(`chrome-extension://${extensionId}/popup.html`);
const resultP = await pageFunc({ page, expect: test.expect });
if (resultP !== undefined) console.log(resultP);

await sleep(100);
await sleep(400);

const resultA = await worker.evaluate(afterFunc);
if (resultA !== undefined) console.log(resultA);
//await sleep(1000000);
Expand All @@ -76,7 +82,11 @@ export const testInSupporters = (message, pageFunc) => {
export const testInWorker = (message, workerFunc) => {
test(message, async ({ page, context, extensionId }) => {
const [worker] = context.serviceWorkers();
await sleep(400);

const result = await worker.evaluate(workerFunc);

await sleep(400);
if (result !== undefined) console.log(result);
//await sleep(1000000);
});
Expand Down

0 comments on commit e4c2d7b

Please sign in to comment.