From 60c75501f551a41230d0ec2e58a777aea8cf5e5c Mon Sep 17 00:00:00 2001 From: Brayden Williams <1311325+redstar504@users.noreply.github.com> Date: Tue, 4 Jun 2024 12:30:35 -0700 Subject: [PATCH] configuring e2e CI workflow --- .github/workflows/playwright.yml | 7 ++++--- package.json | 1 + playwright.config.ts | 12 +++++++----- tests/e2e/example.spec.ts | 4 ++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 7278e2e..1e3f65b 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -5,7 +5,10 @@ on: pull_request: branches: [ main, master ] jobs: - test: + e2e-test: + env: + CI: true + E2E_PORT: 4000 timeout-minutes: 60 runs-on: ubuntu-latest steps: @@ -17,8 +20,6 @@ jobs: run: npm ci - name: Install Playwright Browsers run: npx playwright install --with-deps - - name: Run demo server - run: npm run dev - name: Run Playwright tests run: npx playwright test - uses: actions/upload-artifact@v4 diff --git a/package.json b/package.json index e199754..7a11b34 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "build:demo": "tsc && vite build", "build:lib": "tsc && vite build --config vite.config.lib.ts", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "start-test-server": "npm run preview -- --port 4000", "preview": "vite preview" }, "peerDependencies": { diff --git a/playwright.config.ts b/playwright.config.ts index dc315d1..ea51518 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -9,6 +9,7 @@ import { defineConfig, devices } from '@playwright/test'; /** * See https://playwright.dev/docs/test-configuration. */ + export default defineConfig({ testDir: './tests/e2e', /* Run tests in files in parallel */ @@ -69,9 +70,10 @@ export default defineConfig({ ], /* Run your local dev server before starting the tests */ - // webServer: { - // command: 'npm run start', - // url: 'http://127.0.0.1:3000', - // reuseExistingServer: !process.env.CI, - // }, + webServer: { + command: 'npm run start-test-server', + url: 'http://localhost:4000/lexical-anchorpoint/', + reuseExistingServer: true, + timeout: 120 * 1000, + } }); diff --git a/tests/e2e/example.spec.ts b/tests/e2e/example.spec.ts index 5b63851..6316c71 100644 --- a/tests/e2e/example.spec.ts +++ b/tests/e2e/example.spec.ts @@ -2,7 +2,7 @@ import { test, expect } from '@playwright/test'; import { prettifyHTML } from '../utils' test('typing plain text in the editor', async ({page}) => { - await page.goto('http://localhost:5172') + await page.goto('http://localhost:4000/lexical-anchorpoint/') const editor = page.locator('div[contenteditable=true]').first() await editor.focus() await page.keyboard.type('hello world') @@ -19,7 +19,7 @@ test('typing plain text in the editor', async ({page}) => { }) test('typing links into the editor', async ({page}) => { - await page.goto('http://localhost:5172') + await page.goto('http://localhost:4000/lexical-anchorpoint/') const editor = page.locator('div[contenteditable=true]').first() await editor.focus() await page.keyboard.type(