diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b8e6b6a..71d6208 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -27,7 +27,7 @@ jobs: - name: Install Playwright run: npx playwright install --with-deps - name: Run your tests - run: npm test + run: pnpm run test - name: Upload test results if: always() uses: actions/upload-artifact@v2 diff --git a/.gitignore b/.gitignore index 3f28053..f3198e7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ node_modules /build /functions .env + +General +test-results diff --git a/frontend/package.json b/frontend/package.json index 381d2bb..7ff4842 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -3,7 +3,7 @@ "scripts": { "dev": "vite dev", "build": "vite build", - "preview": "svelte-kit preview", + "preview": "vite preview --port 3000", "check": "svelte-check --tsconfig tsconfig.json", "licenses": "license-checker --summary > licenses.csv", "locale:download": "node scripts/locale.js" diff --git a/package.json b/package.json index 65131b4..bd95ebf 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,14 @@ "dev:front": "pnpm --prefix frontend run dev", "dev:proxy": "node proxy.mjs", "dev": "run-p dev:*", + "test": "playwright test", + "ci:server": "run-p ci:server:*", + "ci:server:backend": "cd backend && cargo run", + "ci:server:front": "pnpm --prefix frontend run preview", + "ci:server:proxy": "node proxy.mjs", "ci:prepare": "run-p ci:prepare:*", "ci:prepare:backend": "cd backend && cargo build", - "ci:prepare:front": "pnpm --prefix frontend install" + "ci:prepare:front": "pnpm --prefix frontend install && pnpm --prefix frontend run build" }, "devDependencies": { "@playwright/test": "^1.23.4", diff --git a/playwright.config.ts b/playwright.config.ts index 6b76c3f..d38c80c 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,18 +1,25 @@ -import type { PlaywrightTestConfig } from '@playwright/test' +import { devices, type PlaywrightTestConfig } from '@playwright/test' const config: PlaywrightTestConfig = { use: { - video: 'on-first-retry', + video: 'retain-on-failure', baseURL: 'http://localhost:1234', - actionTimeout: 3_000, + // actionTimeout: 10_000, }, + outputDir: './test-results', testDir: './test', testMatch: /.*\.ts/, webServer: { - command: 'pnpm run dev', + command: 'pnpm run ci:server', port: 1234, reuseExistingServer: true, + timeout: 20_000, }, + projects: [ + { name: 'Chrome', use: { ...devices['Desktop Chrome'] } }, + { name: 'Firefox', use: { ...devices['Desktop Firefox'] } }, + { name: 'Safari', use: { ...devices['Desktop Safari'] } }, + ], } export default config diff --git a/test/text.ts b/test/text.ts index 0df21bd..98dc197 100644 --- a/test/text.ts +++ b/test/text.ts @@ -18,6 +18,7 @@ async function checkLinkForText(page: Page, link: string, text: string) { } async function checkLinkDoesNotExist(page: Page, link: string) { + await page.goto('/') // Required due to firefox: https://github.com/microsoft/playwright/issues/15781 await page.goto(link) await expect(page.locator('main')).toContainText('note was not found or was already deleted') }