|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +import fs from "node:fs"; |
| 4 | +import path from "node:path"; |
| 5 | +import { fileURLToPath } from "node:url"; |
| 6 | +import { readFileSync } from "node:fs"; |
| 7 | + |
| 8 | +const __filename = fileURLToPath(import.meta.url); |
| 9 | +const __dirname = path.dirname(__filename); |
| 10 | + |
| 11 | +console.log("Verifying Playwright E2E test setup...\n"); |
| 12 | + |
| 13 | +// Check if package.json has Playwright |
| 14 | +const packageJson = JSON.parse( |
| 15 | + readFileSync(path.join(__dirname, "..", "package.json"), "utf8"), |
| 16 | +); |
| 17 | +const hasPlaywright = |
| 18 | + packageJson.devDependencies["@playwright/test"] && |
| 19 | + packageJson.devDependencies.playwright; |
| 20 | +console.log(`✓ Playwright in package.json: ${hasPlaywright ? "Yes" : "No"}`); |
| 21 | + |
| 22 | +// Check test scripts |
| 23 | +const hasTestScripts = |
| 24 | + packageJson.scripts["test:e2e"] && packageJson.scripts["test:e2e:ui"]; |
| 25 | +console.log(`✓ Test scripts configured: ${hasTestScripts ? "Yes" : "No"}`); |
| 26 | + |
| 27 | +// Check directory structure |
| 28 | +const dirs = ["fixtures", "tests", "utils"]; |
| 29 | +for (const dir of dirs) { |
| 30 | + const exists = fs.existsSync(path.join(__dirname, dir)); |
| 31 | + console.log(`✓ Directory e2e/${dir}: ${exists ? "Exists" : "Missing"}`); |
| 32 | +} |
| 33 | + |
| 34 | +// Check test files |
| 35 | +const testFiles = [ |
| 36 | + "fixtures/test-base.ts", |
| 37 | + "fixtures/auth.ts", |
| 38 | + "fixtures/chat.ts", |
| 39 | + "tests/smoke.spec.ts", |
| 40 | + "tests/auth.spec.ts", |
| 41 | + "tests/chat.spec.ts", |
| 42 | + "tests/mobile.spec.ts", |
| 43 | + "utils/mock-api.ts", |
| 44 | +]; |
| 45 | + |
| 46 | +console.log("\nTest files:"); |
| 47 | +for (const file of testFiles) { |
| 48 | + const exists = fs.existsSync(path.join(__dirname, file)); |
| 49 | + console.log(` ${exists ? "✓" : "✗"} ${file}`); |
| 50 | +} |
| 51 | + |
| 52 | +// Check Playwright config |
| 53 | +const configExists = fs.existsSync( |
| 54 | + path.join(__dirname, "..", "playwright.config.ts"), |
| 55 | +); |
| 56 | +console.log(`\n✓ playwright.config.ts: ${configExists ? "Exists" : "Missing"}`); |
| 57 | + |
| 58 | +// Installation status |
| 59 | +try { |
| 60 | + await import("@playwright/test"); |
| 61 | + console.log("\n✓ Playwright is installed"); |
| 62 | +} catch (e) { |
| 63 | + console.log("\n✗ Playwright is NOT installed. Run: pnpm install"); |
| 64 | +} |
| 65 | + |
| 66 | +console.log("\nSetup verification complete!"); |
| 67 | +console.log("\nNext steps:"); |
| 68 | +console.log("1. Run: pnpm install"); |
| 69 | +console.log("2. Run: pnpm exec playwright install --with-deps"); |
| 70 | +console.log("3. Run: pnpm test:e2e"); |
0 commit comments