testing-fundamentals

testing-fundamentals is a cursor rule for Cursor from tugkanboz/awesome-cursorrules. It costs 26 tokens per session (1,820 once invoked), scanned A, original, MIT.

A set of core Cypress rules for end-to-end browser tests, which check complete user flows in an application. It covers stable selectors, automatic waiting, independent tests, and clear checks of expected results.

In plain words
What is it for?
Use it when writing or reviewing Cypress tests for web pages, especially to choose reliable selectors, wait for application state, isolate tests, and verify outcomes.
Why use it?
It helps prevent tests that fail because they depend on changing CSS classes, fixed delays, or the order in which other tests run. Clear assertions also make failures easier to understand.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/tugkanboz/awesome-cursorrules/testing-fundamentals
Clone the repo
git clone --depth 1 https://github.com/tugkanboz/awesome-cursorrules

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for testing-fundamentals

README.md
[![agentmods](https://agentmods.dev/badge/rules/tugkanboz/awesome-cursorrules/testing-fundamentals.svg)](https://agentmods.dev/rules/tugkanboz/awesome-cursorrules/testing-fundamentals)
Your own site
<a href="https://agentmods.dev/rules/tugkanboz/awesome-cursorrules/testing-fundamentals"><img src="https://agentmods.dev/badge/rules/tugkanboz/awesome-cursorrules/testing-fundamentals.svg" alt="Measured on agentmods" height="20"></a>
Per session 26 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,820 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00026 $0.01820
Opus 5 $0.00013 $0.00910
Sonnet 5 $0.00005 $0.00364
Haiku 4.5 $0.00003 $0.00182

Measured 5d ago against content hash bd68c40250b0, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

testing-fundamentals scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

example-structures/cypress/.cursor/rules/testing-fundamentals.mdc · 240 lines

How it starts

The opening of the file, as written. The whole thing — 240 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Cypress Testing Fundamentals

Core Testing Principles

  • Reliable Selectors: Use data attributes for stable element identification
  • Smart Waits: Leverage Cypress's automatic waiting capabilities
  • Test Isolation: Each test should be independent and repeatable
  • Clear Assertions: Write descriptive assertions that explain expected behavior

Element Selection Excellence

// ✅ Best Practice - Use data-cy attributes
cy.get('[data-cy=login-button]').click()
cy.get('[data-cy=username-input]').type('[email protected]')
cy.get('[data-cy=password-input]').type('password123')

// ✅ Alternative - Use data-testid
cy.get('[data-testid=submit-form]').click()

// ✅ Accessible selectors
cy.get('[aria-label="Close dialog"]').click()
cy.get('button').contains('Save Changes').click()

// ❌ Avoid - Brittle CSS selectors
cy.get('.btn-primary.large-button:nth-child(2)').click() // Fragile
cy.get('#dynamic-id-12345').type('text') // IDs may change

Smart Waiting Strategies

// ✅ Wait for element to be visible and interactable
cy.get('[data-cy=submit-button]')
  .should('be.visible')
  .and('not.be.disabled')
  .click()

// ✅ Wait for specific content
cy.get('[data-cy=user-name]')
  .should('contain.text', 'John Doe')

// ✅ Wait for element to disappear (loading states)
cy.get('[data-cy=loading-spinner]').should('not.exist')

// ✅ Wait for API calls to complete
cy.intercept('POST', '/api/users').as('createUser')
cy.get('[data-cy=create-user-form]').submit()
cy.wait('@createUser').then((interception) => {
  expect(interception.response.statusCode).to.equal(201)
})

// ✅ Custom wait conditions
cy.get('[data-cy=dynamic-content]').should(($el) => {
  expect($el).to.have.length.at.least(1)
  expect($el.text()).to.match(/Expected Pattern/)
})

Test Structure and Organization

describe('User Authentication Flow', () => {
  beforeEach(() => {
    // Set up consistent test state
    cy.visit('/login')
    cy.clearLocalStorage()
    cy.clearCookies()
  })

  context('Valid Login Scenarios', () => {
    it('should successfully log in with valid credentials', () => {
      // Arrange
      const userData = {
        email: '[email protected]',
        password: 'validPassword123'
      }

      // Act
      cy.get('[data-cy=email-input]').type(userData.email)
      cy.get('[data-cy=password-input]').type(userData.password)
      cy.get('[data-cy=login-button]').click()

      // Assert
      cy.url().should('include', '/dashboard')
      cy.get('[data-cy=welcome-message]')
        .should('be.visible')
        .and('contain.text', 'Welcome back!')
      
      // Verify user data is loaded
      cy.get('[data-cy=user-profile]')
        .should('contain.text', userData.email)
    })

    it('should remember user when "Remember me" is checked', () => {
      cy.get('[data-cy=email-input]').type('[email protected]')
      cy.get('[data-cy=password-input]').type('password123')
      cy.get('[data-cy=remember-me-checkbox]').check()
      cy.get('[data-cy=login-button]').click()

      // Verify login success
      cy.url().should('include', '/dashboard')

      // Simulate browser restart by clearing session
      cy.clearCookies({ domain: null })
      cy.visit('/login')

      // Verify user is still remembered
      cy.get('[data-cy=email-input]')
        .should('have.value', '[email protected]')
    })
  })

  context('Invalid Login Scenarios', () => {
    it('should display error for invalid credentials', () => {
      cy.get('[data-cy=email-input]').type('[email protected]')
      cy.get('[data-cy=password-input]').type('wrongPassword')
      cy.get('[data-cy=login-button]').click()

      // Verify error handling
      cy.get('[data-cy=error-message]')
        .should('be.visible')
        .and('contain.text', 'Invalid credentials')
      
      // Verify user stays on login page
      cy.url().should('include', '/login')
      
      // Verify form state
      cy.get('[data-cy=password-input]').should('have.value', '')
      cy.get('[data-cy=email-input]').should('have.value', '[email protected]')
    })

    it('should validate required fields', () => {
      // Test empty form submission
      cy.get('[data-cy=login-button]').click()

      cy.get('[data-cy=email-error]')
        .should('be.visible')
        .and('contain.text', 'Email is required')

      cy.get('[data-cy=password-error]')
        .should('be.visible')
        .and('contain.text', 'Password is required')
    })
  })
})

Read the full file on GitHub · 240 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 240 lines · 26 tokens per session scan A bd68c40250b0

Subscribe to this mod's changes

testing-fundamentals is a cursor rule published in the GitHub repository tugkanboz/awesome-cursorrules (20 stars, last pushed yesterday), licensed MIT. It adds 26 tokens to every session and 1,820 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.