SPB Git forge

spb/toveli

Public
14commits 1branches 0releases
1.1 MBsize
maindefault branch
2 h agolast push
TypeScript 50.6% JavaScript 46.1% SQL 2.1% Shell 0.6% CSS 0.5%
1.4 KB · 20 lines javascript
Raw Blame History
1// Captures d'écran QA : node scripts/screenshots.mjs <baseUrl> <outDir>2import { chromium, devices } from "playwright";3const [base = "https://www.toveli.ca", out = "/tmp/toveli-shots"] = process.argv.slice(2);4import { mkdirSync } from "node:fs";5mkdirSync(out, { recursive: true });6const pages = ["/", "/recherche?marche=achat&ville=Qu%C3%A9bec", "/carte", "/estimer?q=1234+erables", "/marche", "/financement", "/assistant", "/favoris", "/connexion"];7const browser = await chromium.launch();8for (const [name, ctxOpts] of [["mobile", { ...devices["iPhone 14"] }], ["android", { ...devices["Pixel 7"] }], ["desktop", { viewport: { width: 1440, height: 900 } }]]) {9  const ctx = await browser.newContext(ctxOpts); const page = await ctx.newPage();10  const errors = [];11  page.on("pageerror", (e) => errors.push(`${name} pageerror: ${e.message}`)); page.on("console", (m) => { if (m.type() === "error") errors.push(`${name} console: ${m.text().slice(0, 160)}`); });12  for (const p of pages) {13    try { await page.goto(base + p, { waitUntil: "networkidle", timeout: 45000 }); await page.waitForTimeout(800); await page.screenshot({ path: `${out}/${name}${p.replace(/[^a-z0-9]+/gi, "_") || "_home"}.png`, fullPage: !p.startsWith("/carte") }); console.log("ok", name, p); }14    catch (e) { console.log("ERR", name, p, e.message.slice(0, 120)); }15  }16  if (errors.length) console.log(errors.slice(0, 12).join("\n"));17  await ctx.close();18}19await browser.close();20