From 6edb5f8462edb53c19c514cc6510fb350da23816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= Date: Thu, 26 Sep 2024 12:40:11 +0800 Subject: [PATCH] Playwright Tests 1240 --- .github/workflows/ci.yaml | 22 +++++++++++----------- .github/workflows/playwright.yml.off | 1 + playwright.config.ts | 1 - tests/example.spec.ts | 18 ------------------ tests/test-1.spec.ts | 6 ++++++ 5 files changed, 18 insertions(+), 30 deletions(-) delete mode 100644 tests/example.spec.ts create mode 100644 tests/test-1.spec.ts diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 12d32d2..a40b701 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -67,17 +67,17 @@ jobs: cp dist/index.html dist/200.html pnpx surge dist https://vue-ts-example.surge.sh --token ${{ secrets.SURGE_TOKEN }} - test: - needs: build-and-deploy - timeout-minutes: 60 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: lts/* - - name: Install dependencies - run: npm install -g pnpm && pnpm install + # test: + # needs: build-and-deploy + # timeout-minutes: 60 + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-node@v4 + # with: + # node-version: lts/* + # - name: Install dependencies + # run: npm install -g pnpm && pnpm install - name: Install Playwright Browsers run: pnpm exec playwright install --with-deps - name: Run Playwright tests diff --git a/.github/workflows/playwright.yml.off b/.github/workflows/playwright.yml.off index 47a9eca..2731bbb 100644 --- a/.github/workflows/playwright.yml.off +++ b/.github/workflows/playwright.yml.off @@ -1,3 +1,4 @@ +# https://vercel.com/guides/how-can-i-run-end-to-end-tests-after-my-vercel-preview-deployment name: Playwright Tests on: push: diff --git a/playwright.config.ts b/playwright.config.ts index 29296f0..f4d97eb 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -26,7 +26,6 @@ export default defineConfig({ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ - // https://vercel.com/guides/how-can-i-run-end-to-end-tests-after-my-vercel-preview-deployment baseURL: process.env.BASE_URL || 'https://vue-ts-example.oo1.dev', /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ diff --git a/tests/example.spec.ts b/tests/example.spec.ts deleted file mode 100644 index 54a906a..0000000 --- a/tests/example.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { test, expect } from '@playwright/test'; - -test('has title', async ({ page }) => { - await page.goto('https://playwright.dev/'); - - // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/Playwright/); -}); - -test('get started link', async ({ page }) => { - await page.goto('https://playwright.dev/'); - - // Click the get started link. - await page.getByRole('link', { name: 'Get started' }).click(); - - // Expects page to have a heading with the name of Installation. - await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); -}); diff --git a/tests/test-1.spec.ts b/tests/test-1.spec.ts new file mode 100644 index 0000000..2f87504 --- /dev/null +++ b/tests/test-1.spec.ts @@ -0,0 +1,6 @@ +import { test, expect } from '@playwright/test'; + +test('test', async ({ page }) => { + await page.goto('/'); + await expect(page.getByRole('link', { name: '中文-页面.page.vue' })).toBeVisible(); +});