RepositoryJavaScriptUSHoa Kỳ
bahmutov

bahmutov/next-and-cypress-example

Next.js example instrumented for code coverage from Cypress tests

137sao
22fork
9issue
2lượt xem

🎯 Next.js + Cypress: Đo code coverage chuẩn 100% từ frontend đến backend

Một ví dụ thực tế kết hợp Next.js và Cypress với hệ thống đo đạt code coverage hoàn chỉnh, bao gồm cả phần frontend và backend thông qua API route.

Đây là dự án mẫu do Gleb Bahmutov tạo ra, nhằm minh họa cách cài đặt và sử dụng Cypress để kiểm thử end-to-end đồng thời thu thập metrics về độ phủ mã nguồn (code coverage). Dự án sử dụng Next.js như framework phát triển web, Cypress làm công cụ kiểm thử, và tích hợp công cụ đo đạt coverage thông qua các plugin hỗ trợ.

✨ Điểm nổi bật

  • Cài đặt nhanh: Chỉ cần chạy npm install và npm run e2e để khởi động cả ứng dụng và Cypress runner.
  • Đo coverage frontend: Sử dụng plugin Babel istanbul trong .babelrc để instrument mã nguồn frontend.
  • Đo coverage backend: Tạo endpoint API tại pages/api/__coverage__.js để lấy dữ liệu coverage từ server-side.
  • Báo cáo chi tiết: Kết quả được lưu trong thư mục coverage, hỗ trợ đa định dạng bao gồm HTML để dễ đọc.
  • Kiểm tra ngưỡng tối thiểu: Chạy script npx nyc report để kiểm tra xem coverage có duy trì trên 100% hay không.
  • Hỗ trợ CI/CD: Tích hợp sẵn với CircleCI để tự động thu thập và kiểm tra coverage sau mỗi lần build.
  • Cấu hình linh hoạt: Cấu hình URL endpoint coverage qua biến môi trường trong cypress.json.
  • Mã nguồn mở MIT: Tự do sử dụng và điều chỉnh theo nhu cầu dự án.

💡 Vì sao đáng chú ý

Không chỉ là một dự án demo đơn thuần, Next.js and Cypress example cung cấp một quy trình làm việc hoàn chỉnh từ viết test, chạy test cho đến việc thu thập và phân tích coverage. Điểm mạnh nằm ở khả năng hỗ trợ đo đạt cả frontend lẫn backend – điều mà nhiều dự án chưa tận dụng hết tiềm năng.

Với cấu hình đơn giản và các script kiểm tra tự động như kiểm tra ngưỡng coverage 100%, dự án rất phù hợp cho các nhóm phát triển muốn áp dụng chuẩn kiểm thử chất lượng cao trong dự án Next.js của mình.


#Nextjs #Cypress #CodeCoverage #Testing #OpenSource #TiniX

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryJavaScript
elaichenkov/cy-verify-downloads

Cypress custom command to wait and verify that file has been downloaded

71
Jan 26, 2026
RepositoryJavaScript
Shelex/cypress-allure-plugin-example

example of cypress + cypress-allure-plugin + github action as CI + allure hosted as github page, report:

53
Mar 28, 2025
RepositoryTypeScript
bahmutov/test-todomvc-using-app-actions

Example Cypress tests going from page objects to app actions

103
Nov 16, 2026
RepositoryTypeScript
riccardogiorato/cypress-for-everything

Cypress to test everything! - Do all kind of tests with Cypress ranging from Http Redirects, Seo, Logins, Emails and much more!

79
Apr 14, 2026
RepositoryJavaScript
vercel/next.js

The React Framework

143.9k
Dec 1, 2026
RepositoryJavaScript
vercel/next.js

The React Framework

143.9k
Dec 1, 2026
RepositoryPython
langgenius/dify

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

162.3k
Dec 2, 2026
RepositoryTypeScript
shadcn-ui/ui

Composable, accessible components with thoughtful defaults. Build your own component library with code you can customize, extend, and make your own.

129.8k
Dec 2, 2026
Modelsentence-similarity
sentence-transformers/all-MiniLM-L6-v2

all-MiniLM-L6-v2 This is a sentence-transformers(https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search. Usage (Sentence-Transformers) Using t...

♥0
157.6M
Jun 1, 2026