DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober 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 PC×
Skip to content
World desk6 min

How to Use the Cypress Component Test Runner

Set up Cypress Component Testing with the Launchpad, configure its dev server, mount a component in a real browser, and fix common configuration snags.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To use Cypress Component Testing, install Cypress in your project, open the Cypress App, choose Component Testing, and follow its Launchpad to configure your framework and bundler. Then create a component spec, mount the component, and use Cypress commands to interact with it and check its behavior in a real browser. The exact setup depends on your framework and versions, so confirm the current Cypress compatibility table before you begin.

What Cypress Component Testing runs

Component tests mount an individual UI component in a browser-based testbed. They are different from end-to-end tests: an end-to-end test visits a running application, while a component test renders the component under test directly. Cypress starts a development server to compile and serve component specs and support files, using the framework and bundler configured for the project.

Because the component runs in a real browser rather than a simulated DOM, you can inspect its rendered output and use browser developer tools while testing. The Cypress App provides the visual test runner for viewing and debugging component tests.

Check framework and bundler support first

The official Cypress getting-started guide, checked on October 3, 2026, documents the combinations below. This is a version-specific snapshot, not a guarantee for every project configuration; check the live guide when setting up.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Framework or library Documented bundler Version context
React Vite 8 or Webpack 5 React 18–19
Next.js Webpack 5 Next.js 15–16; React 18–19
Vue Vite 8 or Webpack 5 Vue 3
Angular Webpack 5 Angular 21–22
Svelte Vite 8 or Webpack 5 Svelte 5; integrations marked Alpha
Qwik and Lit Community integrations Community-maintained; consult the relevant framework definition

For community integrations, Cypress’s custom frameworks guide describes framework definitions and mount adapters. These are not the usual first setup path for a framework Cypress supports directly.

Install Cypress and open Component Testing

  1. From your project root, add Cypress as a development dependency using your package manager:

    npm install cypress --save-dev
    # or: yarn add cypress --dev
    # or: pnpm add --save-dev cypress
    # or: bun add --dev cypress
  2. Open the Cypress App:

    npx cypress open

    Use the equivalent open command for your package manager if needed.

  3. In the App, choose Component Testing. The Launchpad detects the project’s framework and bundler, checks required dependencies, and proposes configuration. Review the changes, then continue to choose a browser.

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

The Launchpad-generated setup is normally sufficient for a conventional supported framework and bundler. Cypress includes its Vite and Webpack dev-server implementations, so a standard setup usually does not require installing a separate Cypress dev-server package.

Understand the generated configuration

The key setting is component.devServer. Its framework and bundler values need to match your application. For example, a React project using Vite may have a configuration shaped like this:

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  component: {
    devServer: {
      framework: 'react',
      bundler: 'vite',
    },
  },
})

This is an illustrative configuration, not a universal pair of values: use the matching framework and bundler for your project. Cypress documents devServer as required for component testing. See component framework configuration and the configuration reference.

Specs and shared setup

By default, Cypress looks for component specs with .cy.js, .cy.jsx, .cy.ts, or .cy.tsx extensions. If your tests live elsewhere or use a different naming pattern, configure component.specPattern; for example, you can limit discovery to files under src.

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

The default component support file is cypress/support/component.js. Put setup shared by component specs there. The component index HTML is cypress/support/component-index.html; use it for global assets such as stylesheets, fonts, or scripts that components need in the testbed.

Write and run your first component test

  1. Create a spec matching the configured component spec pattern, such as src/Counter.cy.jsx.

  2. Import the component and the mount helper documented for your framework, then mount the component in a test. Cypress’s mount imports and examples are framework-specific; follow the relevant official guide rather than assuming the React import works for Vue, Angular, or Svelte.

  3. Select rendered elements, interact with them using Cypress commands, and assert the visible result or behavior. The basic sequence is mount, find, act, and verify.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  4. In the Cypress App, start Component Testing in your selected browser. Inspect the rendered component and test output; use browser developer tools when you need to examine the DOM, styles, or runtime errors.

For framework-specific mount and interaction examples, see Cypress’s React examples and its Vue component testing guide.

Configuration choices and common snags

Use the application’s real bundler configuration

Start with the framework and bundler values identified by the Launchpad. Cypress can reuse discoverable standalone Vite or Webpack configuration, which helps avoid duplicating the application’s build setup. If the detected bundler does not match the project, correct the configuration rather than trying to debug a component against the wrong transforms.

Aliases may need to be declared explicitly

Cypress does not execute meta-framework configuration such as nuxt.config to derive generated bundler settings. If component imports fail because an alias is unavailable, add the necessary alias to the Cypress Vite or Webpack configuration. Cypress documents Nuxt 3 and later component testing as Vue 3 with Vite, but does not provide a dedicated Nuxt framework definition or read nuxt.config; see the Vue guide.

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.

Leave the public path alone unless you need it

devServerPublicPathRoute controls the route Cypress uses to load compiled specs and assets. An incorrect override can stop them from loading. Most projects should keep the default unless there is a specific routing need.

Use a custom dev server only for a real integration need

The standard component.devServer framework-and-bundler configuration is the normal route. A custom devServer function is an advanced option for a non-Vite or non-Webpack bundler, or for a workflow requiring more control over server startup. It must return the server port and may provide a close callback. A custom setup also needs to serve the index HTML and inject support-file and spec imports in the required order.

Recheck changing compatibility entries

Framework and bundler majors change over time, and the current Cypress guide marks its Svelte 5 integrations Alpha. Check the official compatibility page at setup time, especially before relying on a combination in a production workflow.

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

Troubleshoot common setup failures

Symptom Likely cause What to check
The Launchpad proposes a framework or bundler that does not match the app Detection did not identify the project’s actual configuration. Set component.devServer.framework and bundler to the application’s real framework and bundler, and verify the pairing in the current compatibility guide.
Imports using an alias fail in component specs The alias exists in meta-framework configuration that Cypress does not execute to derive bundler settings. Declare the required alias in the Cypress Vite or Webpack configuration.
Specs or assets do not load after changing a path setting devServerPublicPathRoute may point to the wrong route. Remove the override or correct it, then retry with the default if there is no specific reason to customize it.
A spec is not discovered The filename does not match a default extension or the configured component.specPattern. Rename the spec to a supported .cy.* extension or update the pattern to include its location and extension.
Mount setup differs from an example found online Mount helpers are framework-specific, and examples for another framework may use a different import or API. Use the example for your configured framework in the official component-testing documentation.
The project uses an unsupported bundler or needs a preview-server workflow The standard bundled Vite/Webpack dev-server setup may not cover that workflow. Review the custom dev-server requirements and return the server port; ensure the index HTML and support/spec imports are served in the required order.

When to choose component testing

  • Choose component testing when you want to mount and exercise a component in browser rendering without navigating through the full application.
  • Choose end-to-end testing when the behavior you need to verify depends on visiting the running application and exercising flows across it.
  • Check integration fit when deciding: confirm that Cypress documents your framework and bundler versions, and account for any explicit aliases or custom server work your project needs.

Cypress’s component runner uses the application’s development transforms and browser rendering, but the setup is not identical to running the complete deployed or staging app. The official setup material does not establish a general performance advantage over other test approaches.

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

Or skip the browser setup

If your goal is a website screenshot rather than testing an interactive component, ScreenshotNeo can capture a URL with one request. For example:

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 request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and the Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up free for 1,000 screenshots a month with no card.

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.

Leave a Reply

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

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.

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
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.