Trung BìnhTesting iconTesting

Cypress là gì? Khác gì với Selenium?

Cypress chạy trong cùng event loop với app (không qua WebDriver) — time-travel debugging, auto-retry, và cy.intercept() là điểm mạnh; nhược điểm: chỉ Chromium+Firefox, không support multiple tabs, không có async/await native.

  • Cypress là E2E testing framework chạy trong browser (không qua WebDriver protocol như Selenium).
  • Architecture khác biệt: Cypress chạy trong cùng event loop với app — có thể access application state, intercept network requests, control timers trực tiếp.
  • Time-travel debugging: mỗi command được snapshot, hover qua command list để xem DOM state tại từng bước — exceptional debugging experience.
  • Automatic waiting: Cypress tự retry assertions cho đến khi pass hoặc timeout — không cần manual sleep/waitForElement như Selenium. cy.intercept() cho network stubbing: mock API responses, simulate network errors, wait for specific requests to complete.
  • Component testing: Cypress Component Testing mount individual components trong isolation — alternative cho Jest + Testing Library với real browser. cy.session() để cache và reuse authentication state giữa tests — giảm login overhead.
  • Cypress Cloud: parallel test execution, flaky test detection, video recording.
  • Nhược điểm: chỉ support Chromium-based browsers và Firefox (không có Safari/WebKit); không support multiple tabs trong cùng test; test code phải bất đồng bộ theo Cypress command queue — không dùng async/await thông thường.
  • Thích hợp: rich interactive app testing, khi cần time-travel debugging, single-browser test suites.

Xem toàn bộ Testing cùng filter theo level & chủ đề con.

Mở danh sách Testing