慣性聚合 高效追讀感興趣之博客、新聞、科技資訊
閱原文 以慣性聚合開啟

推薦訂閱源

博客园 - 司徒正美
V
V2EX
T
Tailwind CSS Blog
有赞技术团队
有赞技术团队
aimingoo的专栏
aimingoo的专栏
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
A
About on SuperTechFans
月光博客
月光博客
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
V
Visual Studio Blog
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python)
终到终测试流程
Kyle Y. Pars · 2026-05-24 · via DEV Community

Kyle Y. Parsotan

吾辈当筑之。真实端到端(E2E)测试流程若团队于生产中用之编剧(推荐)及 GitHub Actions。

吾将示汝:

  • E2E testing者何?
  • ⚙️ 演员之设(React应用例)
  • 飞升之 GitHub 动作 CI 管道
  • 影牒檢驗並附圖
  • 產製之至善之道

🧠 0. 端到端測驗者何?

E2E(端到端)測驗者謂:

“若真用者用之,以測汝之應。”

非測其能,乃測:

  • 按其鍵
  • 填其表
  • 導其行
  • API与UI相融

⚔️ 演员与Cypress(速决)

特徵 戏剧家 赛普勒斯(Seepuolese)
迅疾 迅疾 中庸
多浏览器 ✅ 肯定 有制限
友 CI ⭐ 甚善
今之应用 ⭐ 上选

👉 吾将用Playwright (2025年业界标准)


🧱 1. 安装Playwright (React项目)

```bash id="pw1"
npm init playwright@latest




When prompted choose:

* JavaScript or TypeScript (TS recommended)
* Tests folder: `tests`
* GitHub Actions: YES

---

# 📁 2. Project structure



```plaintext id="pw2"
my-app/
 ├── tests/
 │    ├── example.spec.ts
 ├── playwright.config.ts
 ├── package.json

入全屏模式 出全屏模式


🧪 初试端到端(真用户流程)

例:登录流程之试

```ts id="test1"
import { test, expect } from '@playwright/test';

test('用户得成功登录', async ({ page }) => {
await page.goto('http://localhost:3000/login');

俟页填'input[name="email"]'以'test@example.com';
俟页填'input[name="password"]'以'password123';

俟页按'button[type="submit"]';

俟期页有URL(/dashboard/);
});




---

# 🚀 4. Run tests locally



```bash id="run1"
npx playwright test

全屏模式 退出全屏模式

开启界面模式(甚为有益):

```bash id="ui1"
npx playwright test --ui




---

# 📸 5. Auto screenshots on failure

Playwright automatically captures:

* screenshots
* videos
* traces

Enable in config:



```ts id="cfg1"
use: {
  screenshot: 'only-on-failure',
  video: 'retain-on-failure',
  trace: 'on-first-retry'
}

进入全屏模式 退出全屏模式


⚙️ 6. GitHub Actions CI流水线(端到端自动化)

📁 .github/workflows/e2e.yml

```yaml id="ci1"
name: 端到端测试(Playwright)

on:
push:
支系:主支
拉取请求:
支系:主支


任:
运行于:最新版乌班图

steps:
  - uses: actions/checkout@v4

  - name: Setup Node
    uses: actions/setup-node@v4
    with:
      node-version: 20

  - name: Install dependencies
    run: npm install

  - name: Install Playwright browsers
    run: npx playwright install --with-deps

  - name: Run Playwright tests
    run: npx playwright test

全屏模式 退出全屏模式




---

# 🧠 7. What happens in CI



```plaintext id="flow1"
Push code
   ↓
GitHub Actions starts
   ↓
Install dependencies
   ↓
Install browsers (Chromium, Firefox, WebKit)
   ↓
Run E2E tests
   ↓
Pass → allow merge
Fail → block PR + show report

全屏模式 退出全屏模式


📊 8.增HTML测试报告

啟報:

```ts id="rep1"
報者:[['html'], ['列']]




Then in CI:



```yaml id="rep2"
- name: Upload Playwright report
  uses: actions/upload-artifact@v4
  if: always()
  with:
    name: playwright-report
    path: playwright-report

入全屏模式 離全屏模式


🌐 9. 測試實際部署應用(PRO設置)

非localhost:

```ts id="prod1"
待頁面至/https://your-app.vercel.app/login'




👉 This turns it into **true production E2E testing**

---

# 🧪 10. Advanced real-world test examples

---

## 🟢 UI navigation test



```ts id="nav1"
test('navigate to dashboard', async ({ page }) => {
  await page.goto('/');
  await page.click('text=Dashboard');
  await expect(page).toHaveURL(/dashboard/);
});

入全屏模式 出全屏模式


🟡 表单验证测试

```ts id="form1"
测试('邮箱为空时显示错误', async ({ 页面 }) =>> {
期待(页面.goto('/login'));
期待(页面.click('button[type="submit"]'));

俟期,冀页之索「.error」者,含「Email is required」之文;
});




---

## 🔵 API + UI combined test



```ts id="api1"
test('data loads after API call', async ({ page }) => {
  await page.goto('/dashboard');

  await expect(page.locator('.loading')).toBeHidden();
  await expect(page.locator('.chart')).toBeVisible();
});

全屏入; 全屏出;


🔐 11. CI至善之道(要义)

✔ 构建毕,行E2E

```yaml id="bp1"

  • 行:npm run build
  • 行:npm start &```

✔ 使用测试环境

  • staging.example.com
  • production.example.com

✔ 重试不稳之测试

```ts id="zh1"```
重试:二




---

# ⚠️ 12. Common mistakes

### ❌ Testing implementation instead of behavior

Bad:



```ts id="bad1"
expect(component.state).toBe(true)

入全景模式 出全屏模式

善哉

```ts id="善一"
冀页有文曰《迎迓》




---

### ❌ No stable selectors

Use:



```html id="sel1"
data-testid="login-button"

全屏模式 退出全屏模式

则:

```ts id="sel2"
页得测试ID「登录按钮」




---

### ❌ Running E2E without CI

Always run in GitHub Actions

---

# 🧠 Final architecture



```plaintext id="final1"
Push / PR
   ↓
CI (unit tests)
   ↓
E2E tests (Playwright)
   ↓
Build app
   ↓
Deploy to staging/production
   ↓
Report + screenshots stored in GitHub

全屏模式 退出全屏模式


🚀 君所成之器

今君有:

  • 🧪 仿真真人测试
  • 🚀 集成CI/CD端到端流水线
  • 📸 失败截图与视频
  • 🌍 生产就绪测试系统
  • 🔒 安全部署门禁系统