From e4c2d7b3611db66ad7d26d3dfe3e0ef945820e9e Mon Sep 17 00:00:00 2001 From: Toshimitsu Takahashi Date: Fri, 20 Oct 2023 22:41:44 +0900 Subject: [PATCH] update emulator setting and adjust sleep --- playwright.config.ts | 24 ++++++++++++++++++++++++ test/emulator/fixtures.js | 14 ++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 playwright.config.ts diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000..1e1b386 --- /dev/null +++ b/playwright.config.ts @@ -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' + }, + }, + ], +}); diff --git a/test/emulator/fixtures.js b/test/emulator/fixtures.js index c6e1f79..85b375d 100644 --- a/test/emulator/fixtures.js +++ b/test/emulator/fixtures.js @@ -33,6 +33,8 @@ 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); @@ -40,7 +42,8 @@ export const testInOptions = (message, beforeFunc, pageFunc, afterFunc) => { 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); @@ -50,6 +53,8 @@ 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); @@ -57,7 +62,8 @@ export const testInPopup = (message, beforeFunc, pageFunc, afterFunc) => { 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); @@ -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); });