October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Use Cypress for End-to-End Testing

A practical Cypress E2E guide: install the package, generate the setup, write a user-centered spec, run it locally, and configure CI readiness.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To use Cypress for end-to-end (E2E) testing, install it in your project, open Cypress and choose End-to-End Testing, start your application, then write specs that visit pages, interact with the interface, and assert the resulting state. Use npx cypress open for interactive development and npx cypress run for repeatable, headless execution, including in CI.

What Cypress E2E tests verify

An E2E test exercises an application through a browser in the way a user would, checking that a complete journey works across the application. For example, a test might open a page, follow a link, and verify that the destination or resulting content is correct. Use E2E tests for important flows that depend on the integrated application, rather than treating every isolated UI behavior as an E2E test.

As an Amazon Associate I earn from qualifying purchases.

Component testing has a narrower scope: it mounts a component in isolation. Cypress’s documentation describes E2E setup and maintenance as potentially more demanding than component testing, so choose the test type that matches the behavior you need to verify. Cypress: Why Cypress?

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Cypress in your project

From the project root, add cypress as a development dependency using the package manager the project already uses. Cypress’s installation guide lists commands for npm, Yarn, pnpm, and Bun, along with system requirements. On Linux, check whether the environment needs additional libraries. Newer npm releases can also require an allowScripts configuration change for install scripts, so follow the current installation guide if Cypress’s postinstall step does not run as expected.

Use the package manager’s Cypress command after installation. For an npm project, the first launch is:

npx cypress open

See the current Cypress installation instructions and system requirements for package-manager-specific commands and browser support.

Initialize E2E testing and start the app

Choose E2E testing in Cypress Launchpad

Run npx cypress open from the project root. On first launch, choose End-to-End Testing. Cypress Launchpad creates the initial configuration and project structure for the selected test type. Select E2E when you want to exercise browser journeys through the application; choose component testing when you want to mount and check a component in isolation. See Open the Cypress app.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run the application separately

Start the app with its normal development command in a separate terminal, and confirm it is reachable at its local URL before a spec calls cy.visit(). Cypress documentation advises against starting a web server from inside Cypress scripts. The server must be ready before the browser test begins, especially in CI where startup time can vary. Effective E2E testing

Write a first user-centered spec

Structure each test as setup, action, and assertion—also known as Arrange, Act, Assert or Given, When, Then. Cypress’s first-test tutorial uses Mocha’s describe and it, Chai’s expect, and Cypress commands such as cy.visit(), cy.contains(), and .click().

For example, create cypress/e2e/home.cy.js and adapt the local URL and link text to match your application:

describe('home page navigation', () => {
  it('opens the pricing page from the home page', () => {
    cy.visit('http://localhost:3000')

    cy.contains('a', 'Pricing').click()

    cy.url().should('include', '/pricing')
    cy.contains('h1', 'Pricing').should('be.visible')
  })
})

The assertions are essential: a sequence of commands that does not check a meaningful outcome does not establish that the journey worked. Pick selectors and expected results that reflect the real user-visible behavior of your app. The example assumes the app serves its home page on port 3000 and has a link and heading with the shown text; change those values to match your project. Cypress: Write your first E2E test

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run tests interactively or from the command line

Interactive development

Run npx cypress open while authoring tests. The Cypress app provides an interactive way to select and run specs and inspect test behavior in a browser.

Automated or headless execution

Run npx cypress run to execute specs to completion from the command line. CLI run is headless by default. Cypress’s CLI supports selecting a browser or spec when you need to narrow execution; consult the Cypress command-line reference for the current flags and values. Teams can add project scripts for consistent shared commands, for example:

{
  "scripts": {
    "cy:open": "cypress open",
    "cy:run": "cypress run"
  }
}

Use the package-manager script form in your project, such as npm run cy:open or npm run cy:run.

Run Cypress reliably in CI

  1. Install the project dependencies and Cypress in the CI job using the project’s normal package manager.
  2. Start the application in the background or through the CI provider’s supported integration.
  3. Wait for the app to respond at the URL the tests will visit.
  4. Run cypress run after readiness is confirmed.

Do not rely on a fixed sleep or simply start the server and Cypress back-to-back. Cypress’s CI guide notes that a command pattern such as npm start & npx cypress run does not guarantee the server has booted before Cypress starts. Use a readiness check so variable startup times do not create a race failure. Cypress documents examples and integrations for major CI providers in its continuous integration guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Browser support and choosing where to test

According to Cypress’s installation documentation, Chrome, Edge, and Firefox support covers their latest three major versions; WebKit support is experimental, and Electron is deprecated as a test browser. Browser support can change, so verify the current guidance before configuring a browser matrix. Choose coverage based on the browsers your users rely on, and distinguish supported browsers from experimental options. Cypress installation reference

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common setup and test failures

  • Cypress does not install or its postinstall step fails: check the current Cypress system requirements, required Linux libraries, and any npm allowScripts configuration relevant to your npm version.
  • cy.visit() cannot load the page: start the application separately and confirm the exact local URL is reachable before running the spec.
  • Tests fail intermittently in CI at startup: replace arbitrary sleeps or immediate Cypress startup with a check that waits for the server to respond.
  • The test runs but does not catch a broken journey: add an assertion for the outcome that matters, such as the destination URL or visible page content, after the interaction.
  • A browser behaves differently from the configured test browser: verify that browser’s current Cypress support status and run the suite in a browser your users actually use; do not treat experimental WebKit support as equivalent to supported browser coverage.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server, not a replacement for Cypress E2E tests: use Cypress to validate application behavior and ScreenshotNeo when you need a page screenshot or PDF. One GET request returns an image or PDF:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for options and response details. Before capture, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server gives AI agents tools for screenshots, page information, and PDF capture.

The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Does Cypress require a paid plan to run E2E tests locally?

The cited Cypress setup and usage guides describe installing and running the software but do not establish pricing or plan requirements; check Cypress’s current product information for those details.

Can I use Cypress to test a deployed website instead of localhost?

Yes, testing a deployed app can be appropriate, but weigh the risk of disruption and flakiness from external dependencies against the value of testing that environment.

Is Cypress WebKit support ready for a production browser matrix?

The installation guide describes WebKit support as experimental; confirm current Cypress guidance before relying on it for required coverage.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.