Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
IT Security Toolshol-guard(21.09.2026 um 15:59 Uhr)
IT Security NachrichtenNew Exvicy ClickFix Framework Built on Rival ErrTraffic’s Code(21.09.2026 um 17:02 Uhr)
IT Security Nachrichten10 Lessons Reshaping Security After Black Hat and DEF CON 2026(21.09.2026 um 17:03 Uhr)
IT Security NachrichtenMicrosoft Exposes macOS ClickFix Cloaked Gates – Research(21.09.2026 um 17:31 Uhr)
IT Security NachrichtenGoogle Hit with €403m GDPR Fine Over Location Data Practices(21.09.2026 um 17:00 Uhr)
IT Security NachrichtenFrom Love Letters to AI Agents: Cybersecurity’s Evolution(21.09.2026 um 17:00 Uhr)
Sichere ProgrammierungMicrosoft Exposes macOS ClickFix Cloaked Gates – Research(21.09.2026 um 17:04 Uhr)
IT Security NachrichtenWriting Custom Semgrep Rules for Static Analysis(21.09.2026 um 17:25 Uhr)
IT Security Toolshol-guard(21.09.2026 um 15:59 Uhr)
IT Security NachrichtenNew Exvicy ClickFix Framework Built on Rival ErrTraffic’s Code(21.09.2026 um 17:02 Uhr)
IT Security Nachrichten10 Lessons Reshaping Security After Black Hat and DEF CON 2026(21.09.2026 um 17:03 Uhr)
IT Security NachrichtenMicrosoft Exposes macOS ClickFix Cloaked Gates – Research(21.09.2026 um 17:31 Uhr)
IT Security NachrichtenGoogle Hit with €403m GDPR Fine Over Location Data Practices(21.09.2026 um 17:00 Uhr)
IT Security NachrichtenFrom Love Letters to AI Agents: Cybersecurity’s Evolution(21.09.2026 um 17:00 Uhr)
Sichere ProgrammierungMicrosoft Exposes macOS ClickFix Cloaked Gates – Research(21.09.2026 um 17:04 Uhr)
IT Security NachrichtenWriting Custom Semgrep Rules for Static Analysis(21.09.2026 um 17:25 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Core Technical Topics to Master in Cypress for Effective E2E Testing

Core Technical Topics to Master in Cypress for Effective E2E Testing End-to-end (E2E) testing is a crucial part of modern web development, ensuring that applications work as expected from the user’s… Core Technical Topics to …

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!




Core Technical Topics to Master in Cypress for Effective E2E Testing



End-to-end (E2E) testing is a crucial part of modern web development, ensuring that applications work as expected from the user’s…









Core Technical Topics to Master in Cypress for Effective E2E Testing



End-to-end (E2E) testing is a crucial part of modern web development, ensuring that applications work as expected from the user’s perspective. Cypress has emerged as a leading tool for E2E testing due to its speed, reliability, and developer-friendly features.



In this guide, we’ll explore the core technical topics you need to master in Cypress, including writing tests, best practices, and integrating Cypress into CI/CD pipelines.









1. Writing Cypress Tests (Selectors, Commands, Assertions)






Selectors



Cypress provides multiple ways to select DOM elements:




  • cy.get() – Uses CSS selectors (e.g., cy.get('.btn')).

  • cy.contains() – Finds elements by text content (e.g., cy.contains('Submit')).

  • data-* attributes – Best practice for stable selectors (e.g., cy.get('[data-test="login-button"]')).






Commands & Assertions



Cypress chains commands for readability:




cy.visit('/login')    
.get('\[data-test="username"\]').type('testuser')
.get('\[data-test="password"\]').type('password123')
.get('\[data-test="submit"\]').click()
.url().should('include', '/dashboard')






Common assertions:




  • .should('be.visible') – Checks element visibility.

  • .should('have.text', 'Success') – Verifies text content.





Core Technical Topics to Master in Cypress for Effective E2E Testing









2. Page Object Model (POM) in Cypress



The Page Object Model (POM) improves test maintainability by encapsulating page logic:




// pages/LoginPage.js    
class LoginPage {
visit() {
cy.visit('/login');
}

fillUsername(username) {
cy.get('\[data-test="username"\]').type(username);
}
submit() {
cy.get('\[data-test="submit"\]').click();
}
}
export default new LoginPage();






Usage in Tests:




import LoginPage from '../pages/LoginPage';    

describe('Login Test', () => {
it('logs in successfully', () => {
LoginPage.visit();
LoginPage.fillUsername('testuser');
LoginPage.submit();
cy.url().should('include', '/dashboard');
});
});







Benefits:


✔ Reduces code duplication


✔ Easier maintenance


✔ Clear separation of concerns







3. Handling API Requests & Network Interception





cy.request() for API Testing



Cypress can directly call APIs:




cy.request('POST', '/api/login', {    
username: 'testuser',
password: 'password123'
}).then((response) => {
expect(response.status).to.eq(200);
});









cy.intercept() for Mocking & Stubbing



Intercept and mock API calls:




cy.intercept('GET', '/api/users', {    
fixture: 'users.json'
}).as('getUsers');

cy.visit('/dashboard');
cy.wait('@getUsers').then((interception) => {
expect(interception.response.body).to.have.length(3);
});












4. Running Tests on Different Viewports/Devices



Cypress supports responsive testing with cy.viewport():




describe('Responsive Test', () => {    
it('displays correctly on mobile', () => {
cy.viewport('iphone-6');
cy.visit('/');
cy.get('.navbar-toggle').should('be.visible');
});
});






Common Viewports:




  • cy.viewport(1920, 1080) (Desktop)

  • cy.viewport('ipad-2') (Tablet)

  • cy.viewport('samsung-s10') (Mobile)









5. Handling Test Flakiness & Retries






Causes of Flakiness:




  • Dynamic content loading

  • Unstable network requests

  • Race conditions






Solutions:



✔ Use cy.wait() with aliased requests.


✔ Implement retries in cypress.json:




{    
"retries": {
"runMode": 2,
"openMode": 0
}
}






✔ Avoid cy.wait(5000) (prefer cy.get().should()).









6. Using Cypress with GitHub/GitLab CI






GitHub Actions Example:






name: Cypress Tests    
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx cypress run --headless

### GitLab CI Example:

stages:
- test

e2e:
stage: test
image: cypress/base:14
script:
- npm install
- npx cypress run --headless







Key CI Optimizations:




  • Parallelization (--parallel)

  • Caching dependencies for faster runs

  • Artifact storage for test videos/screenshots









Example Question: Structuring Cypress Tests for a Large React App



Best Practices:


✅ Modularize tests (e.g., auth, dashboard, settings).


✅ Use POM for reusable page interactions.


✅ Mock APIs to avoid backend dependencies.


✅ Separate specs by feature (e.g., login.spec.js, checkout.spec.js).


✅ Leverage custom commands for repetitive actions.



Example Structure:



/cypress


/fixtures


- users.json


/integration


/auth


- login.spec.js


- signup.spec.js


/dashboard


- overview.spec.js


/pages


- LoginPage.js


- DashboardPage.js


/support


- commands.js









Conclusion



Mastering Cypress involves understanding:


✔ Writing efficient tests (selectors, assertions).


✔ Using POM for scalability.


✔ Handling APIs & network calls.


✔ Responsive testing across devices.


✔ Reducing flakiness with retries.


✔ CI/CD integration for automated testing.



By applying these techniques, you can build reliable, maintainable, and fast E2E test suites for any web application.



🚀 Ready to supercharge your testing workflow? Start implementing these Cypress best practices today!









Further Reading:








Cypress #Testing #QA #Automation #WebDevelopment #JavaScript #ContinuousIntegration



Would you like a deeper dive into any of these topics? Let me know in the comments! 👇





By Mohamed Said Ibrahim on May 30, 2025.





Exported from Medium on October 2, 2025.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Core Technical Topics to Master in Cypress for Effective E2E Testing

Thematisch verwandte Begriffe: Core, Technical, Topics, Master · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94393 | When a user creates or edits a report inside an event, MISP can identify…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick