diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2f0e55..74a29ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,9 +46,21 @@ jobs: - name: Run tests run: npx vitest run + e2e: + runs-on: runners-cartsnitch + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: "20" + cache: npm + - run: npm ci + - run: npx playwright install --with-deps chromium + - run: npx playwright test + build-and-push: runs-on: runners-cartsnitch - needs: [lint, test] + needs: [lint, test, e2e] outputs: calver_tag: ${{ steps.calver.outputs.version }} steps: @@ -110,7 +122,7 @@ jobs: build-and-push-auth: runs-on: runners-cartsnitch - needs: [lint, test] + needs: [lint, test, e2e] outputs: calver_tag: ${{ steps.calver.outputs.version }} steps: diff --git a/e2e/smoke.spec.ts b/e2e/smoke.spec.ts new file mode 100644 index 0000000..28ec3e1 --- /dev/null +++ b/e2e/smoke.spec.ts @@ -0,0 +1,6 @@ +import { test, expect } from '@playwright/test'; + +test('app loads', async ({ page }) => { + await page.goto('/'); + await expect(page).toHaveTitle(/CartSnitch/); +}); diff --git a/package.json b/package.json index 67e3891..6a2912e 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "lint": "eslint .", "preview": "vite preview", "test": "NODE_ENV=test vitest run", - "test:watch": "NODE_ENV=test vitest" + "test:watch": "NODE_ENV=test vitest", + "test:e2e": "npx playwright test" }, "dependencies": { "@tanstack/react-query": "^5.0.0", @@ -32,6 +33,7 @@ "eslint": "^9.39.4", "eslint-plugin-react-hooks": "^7.0.1", "eslint-plugin-react-refresh": "^0.5.2", + "@playwright/test": "^1.49.0", "globals": "^17.4.0", "jsdom": "^25.0.1", "tailwindcss": "^4.0.0", diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000..a2d7b0b --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,19 @@ +import { defineConfig, devices } from '@playwright/test'; + +export default defineConfig({ + testDir: './e2e', + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + }, + ], + webServer: { + command: 'npm run dev', + url: 'http://localhost:5173', + reuseExistingServer: !process.env.CI, + }, + use: { + baseURL: 'http://localhost:5173', + }, +});