Przejdź do treści
Biblioteka skilli
Programowanie · Testowanie

cypress

/cypress

Pomaga pisać testy E2E i testy komponentów w Cypress, automatyzować przepływy użytkownika i mockować wywołania sieciowe.

Repozytorium
Agent-Skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
01.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
2
Przestarzałość

Brak sygnałów. Repozytorium zmienione 01.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Pomaga pisać testy E2E i testy komponentów w Cypress, automatyzować przepływy użytkownika i mockować wywołania sieciowe.

Oryginalny opis (EN)

Expert Cypress testing assistance covering end-to-end, component testing, and intercepting network calls. Use when writing E2E tests, automating user workflows, or mocking network endpoints.

Jak działa

  1. When to Use
  2. Quick Start
  3. Core Concepts
  4. Common Patterns
  5. Best Practices
  6. Troubleshooting
  7. References
Sekcje z nagłówków SKILL.md, w oryginale · 127 linii, 563 słów
Podgląd SKILL.md
---
name: cypress
description: Expert Cypress testing assistance covering end-to-end, component testing, and intercepting network calls. Use when writing E2E tests, automating user workflows, or mocking network endpoints.
---

# Cypress

Cypress is a next generation front end testing tool built for the modern web. It runs _inside_ the browser (unlike Selenium/Playwright) which gives it native access to the DOM.

## When to Use

- **Component & End-to-End Web Testing**: Running browser-based functional tests directly inside Chrome, Firefox, and Edge.
- **Time-Travel Debugging**: Stepping back through snapshots of DOM state taken during test command execution.
- **Network Interception & Mocking**: Stubbing API responses, delaying network latency, and testing edge error cases with `cy.intercept()`.
- **Component Isolation Testing**: Testing isolated React, Vue, Svelte, or Angular components without bootstrapping full backends.

## Quick Start

```javascript
describe("My First Test", () => {
  it("Visits the Kitchen Sink", () => {
    cy.visit("https://example.cypress.io");
    cy.contains("type").click();
    cy.url().should("include", "/commands/actions");
    cy.get(".action-email")
      .type("fake@email.com")
      .should("have.value", "fake@email.com");
  });
});
```

## Core Concepts

### Asynchronous Command Queuing & Automatic Retries

Cypress commands do not return standard promises; they queue actions that automatically retry until assertions pass or timeout:

```typescript
// cypress/e2e/login.cy.ts
describe("Authentication Flow", () => {
  it("logs in user and displays dashboard", () => {
    cy.visit("/login");

    // Automatically retries until element exists and is visible
    cy.get('input[name="email"]').type("jane@example.com");
    cy.get('input[name="password"]').type("Password123!");
    cy.get('button[type="submit"]').click();

    // Asserts on URL and DOM content
    cy.url().should("include", "/dashboard");
    cy.contains("h1", "Welcome back, Jane").should("be.visible");
  });
});
```

### Network Interception & Dynamic Fixture Stubbing (`cy.intercept`)

Controls and mocks network traffic without external proxy dependencies:

```typescript
it("handles network failure gracefully", () => {
  cy.intercept("GET", "/api/v1/projects", {
    statusCode: 500,
    body: { error: "Internal Server Error" },
  }).as("getProjectsError");

  cy.visit("/projects");
  cy.wait("@getProjectsError");

  cy.get(".error-banner").should("contain.text", "Failed to load projects");
});
```

### Custom Commands & Page Object Encapsulation

Encapsulates reusable user workflows:

```typescript
// cypress/support/commands.ts
Cypress.Commands.add("loginViaApi", (email: string, password: string) => {
  cy.request("POST", "/api/v1/auth/login", { email, password }).then((res) => {
    window.localStorage.setItem("authToken", res.body.token);
  });
});
```

## Common Patterns

### Network Request Interception and Waiting

**Problem**: Flaky tests caused by asserting UI before backend API responses have completed and rendered.

**Solution**:
Use `cy.intercept` with route aliases and `cy.wait`:

```javascript
it("loads and displays user profile data", () => {
  cy.intercept("GET", "/api/v1/user", { fixture: "user.json" }).as("getUser");
  cy.visit("/dashboard");
  cy.wait("@getUser");
  cy.get('[data-cy="user-name"]').should("contain.text", "Jane Doe");
});
```

## Best Practices

**Do**:

- Use Dedicated Test Attributes: Select elements using `data-cy` or `data-testid` (`cy.get('[data-cy="submit"]')`) rather than CSS classes.
- Log In Programmatically via API: Bypass UI login forms in setup hooks using `cy.request()` to accelerate test runs.
- Use `cy.intercept()` for Flake-Free Synchronization: Wait on explicit network aliases (`cy.wait('@loadData')`) rather than `cy.wait(3000)`.
- Keep Tests Independent: Each test must be able to run in isolation without depending on state left by previous tests.

**Don't**:

- Use `async/await` with Cypress commands: Cypress manages its own internal command queue; mixing with `async/await` breaks execution order.
- Use hardcoded `cy.wait(number)`: Static delays make test suites slow and flaky.
- Test third-party OAuth providers through the UI: Mock OAuth callbacks or use API token injection.

## Troubleshooting

| Error                                                | Cause                                                   | Solution                                                                             |
| :--------------------------------------------------- | :------------------------------------------------------ | :----------------------------------------------------------------------------------- |
| `CypressError: Timed out retrying after 4000ms`      | Element not found in DOM or covered by another element. | Check selector specificity and wait for loading spinners to detach.                  |
| `cy.visit() failed trying to load`                   | Target dev server is down or SSL certificate untrusted. | Verify base URL in `cypress.config.js` and set `chromeWebSecurity: false` if needed. |
| `Cannot read properties of undefined (reading 'as')` | Chaining assertions incorrectly on cy.intercept.        | Assign `.as('alias')` immediately on `cy.intercept(...)` declaration.                |

## References

- [Cypress Documentation](https://docs.cypress.io/)

Wersje

RepozytoriumWynikLicencja
Ta strona · G1Joshi/Agent-Skills100MIT
TerminalSkills/skills100Apache-2.0
claude-dev-suite/claude-dev-suite100MIT
aks-builds/quality-skills100MIT

Migawka bazy z 28.10.2026 · wersja paczki a4c250245ba5 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100cypress-expert
    Pomaga w pracy z Cypress: własne polecenia, fixtures, wtyczki, testy wizualne i testy komponentów oraz struktura testów.
  • 90cypress-author
    Tworzy, aktualizuje i naprawia testy Cypress typu E2E i komponentów, także te niestabilne lub zawodzące.
  • 95cypress-component-testing
    Prowadzi przez testy komponentów w Cypress dla React, Vue i Svelte: montowanie, izolację, własne komendy, stubowanie sieci i asercje na snapshotach.
  • 100cypress-skill
    Generuje produkcyjne testy E2E i testy komponentów w Cypress w JavaScript lub TypeScript, z uruchamianiem lokalnym i w chmurze TestMu AI.
  • 100cypress-skill
    Generuje produkcyjne testy E2E i testy komponentów w Cypress w JavaScript lub TypeScript, z uruchamianiem lokalnym i w chmurze TestMu AI.
  • 100cypress-fundamentals
    Uczy podstaw Cypress: polecenia, asercje, fixtures i wzorce testów end-to-end.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.