From 6e18e0f73712914f38b1d658af1f6c6876561e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= Date: Mon, 31 Mar 2025 12:36:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20headless=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=94=AF=E6=8C=81=E5=92=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=AF=B7=E6=B1=82=E9=A1=B5=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + playwright.config.ts | 2 +- tests/playwright/api-page.spec.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4632284..bf40c96 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "lint:eslint": "eslint . --fix", "prepare": "husky", "playwright": "playwright test", + "playwright:headless": "HEADLESS=true playwright test", "playwright:ui": "playwright test --ui", "playwright:chromium": "playwright test --project=chromium", "dep:dedupe": "pnpm dedupe", diff --git a/playwright.config.ts b/playwright.config.ts index 66e93b1..cab93b4 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -69,7 +69,7 @@ export default defineConfig({ baseURL: process.env.BASE_URL || 'https://vue-ts-example.oo1.dev', /* Only on CI systems run the tests headless */ - headless: !!process.env.CI, + headless: !!process.env.CI || process.env.HEADLESS === 'true', /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', diff --git a/tests/playwright/api-page.spec.ts b/tests/playwright/api-page.spec.ts index 0fa44d9..986f0cb 100644 --- a/tests/playwright/api-page.spec.ts +++ b/tests/playwright/api-page.spec.ts @@ -1,7 +1,7 @@ import { expect, test } from '@playwright/test'; test('接口请求页面', async ({ page }) => { - await page.goto('/Tool/API'); + await page.goto('/Page/API'); // /fake-api 正常返回。 await expect(page.locator('pre')).toContainText('http://dummyimage.com/200x200'); // // /npm-registry-api 正常返回。