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 desk5 min

How to Get Started with Cypress Component Testing for Vue

Set up Cypress Component Testing for Vue with the Launchpad, then write a first spec that mounts a .vue component and checks its behavior.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To start Cypress Component Testing in a Vue project, install Cypress, open its app, choose Component Testing, and follow the Launchpad to configure the project. Then import a Vue component into a spec, mount it with cy.mount(), and assert what it renders or how it responds to user actions.

What Cypress Component Testing does for Vue

Cypress mounts a component in isolation in a real browser, rather than a simulated DOM or a running production application. That lets you check rendered output and user interactions in a browser environment. Cypress describes this approach in its Component Testing getting-started guide.

As an Amazon Associate I earn from qualifying purchases.

Component tests are useful for focused checks of a component’s behavior. They do not, by themselves, verify that the whole application, its backend, or a deployed page works end to end.

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

Check your Vue and bundler setup

Cypress documents Vue component testing with Vite and Webpack. Its Vue overview lists Vue 3 with Vite 8 and Vue 3 with Webpack 5 or later for the documented paths. These compatibility details can change; check the current Vue component testing guide before installing or upgrading dependencies.

Use the bundler your project already uses. Cypress’s component configuration can discover a Vite or Webpack configuration file by searching upward from the project. In typical setups, you do not need to maintain a second, duplicated bundler configuration. If discovery fails or the component-test environment needs different settings, configure the relevant Vite or Webpack options explicitly; see Cypress’s component framework configuration guide.

Install Cypress and open the Component Testing setup

  1. Install Cypress in the Vue project. From the project directory, run npm install cypress --save-dev. Cypress’s installation guide also documents Yarn, pnpm, and Bun commands.
  2. Open the Cypress app. Run npx cypress open from the same project directory.
  3. Choose Component Testing. In the app, select the Component Testing option to start the setup flow.
  4. Follow the Launchpad. Cypress detects the framework and bundler, checks for required dependencies, and scaffolds the configuration. Review the detected choices, select a browser, and start Component Testing.

The central setting is component.devServer, which tells Cypress how to serve the component-test environment for the selected framework and bundler. The Launchpad usually creates the initial configuration for you. If you need to adjust it, consult the configuration guide linked above.

Write and run your first Vue component spec

Create a spec alongside your component or in the location selected by the Cypress setup. Import the component and mount it with cy.mount(). For example, if your project has a Stepper.vue file next to the spec:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import Stepper from './Stepper.vue'

describe('<Stepper />', () => {
  it('mounts', () => {
    cy.mount(Stepper)
  })
})

This minimal test checks that the component can mount. Add assertions that reflect its intended behavior, such as checking visible text or interacting with a control and verifying the resulting output. Cypress’s Vue examples show patterns for passing props and using a Cypress spy to check a callback prop; the Vue API documents the mount helper.

Test observable behavior

Prefer assertions about what a user can see or do over assertions tied to internal implementation details. For a control, that might mean asserting its initial label, clicking it, and checking the visible result. When a component accepts a callback or event handler as a prop, pass a spy and assert that the interaction called it as expected, following the Cypress examples for the component’s actual API.

Nuxt projects need extra configuration attention

Cypress does not provide a dedicated Nuxt framework definition for component testing and does not execute nuxt.config to recreate Nuxt’s normal environment. Cypress documents Nuxt 3 and later through its Vue with Vite path. In this setup, Nuxt aliases such as @ and ~ may need to be declared in the Cypress Vite configuration. Nuxt auto-imported components and composables are not automatically available to an isolated mounted component: import dependencies explicitly or configure an equivalent plugin for the component-test environment. See the Vue guide and configuration guide.

Troubleshoot common setup problems

  • Cypress does not detect the expected framework or bundler: confirm you opened Cypress from the Vue project directory and that the project’s dependencies and bundler configuration are present. Review the Launchpad detection and the component.devServer configuration.
  • A Vite or Webpack configuration cannot be found: check where the project config lives relative to the component-test setup. Cypress searches upward for a config; if that does not fit the project layout, supply the corresponding explicit configuration option as described in the configuration guide.
  • A component fails to resolve an alias or plugin: the isolated test server may not be using the same alias or plugin setup as the app. Configure the component-test bundler environment to match what the component needs.
  • A Nuxt auto-import or composable is undefined: Cypress does not execute nuxt.config for component testing. Import that dependency in the component or provide the necessary equivalent plugin/configuration in the test environment.
  • The spec mounts but the test does not check meaningful behavior: mounting alone confirms the component can render in the test environment. Add assertions for user-visible output or interactions, and use a spy when verifying a callback prop.

Or skip the browser setup

Cypress Component Testing is for testing Vue components in a browser; ScreenshotNeo is a website screenshot API, not a replacement for component tests. It can be useful when your task is to capture a page by URL instead. One GET request returns an image or PDF. For example, this cURL request saves a WebP screenshot of Stripe:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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. ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

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

Frequently Asked Questions

Can a component spec import styles or other project modules?

Yes, when the component-test bundler environment can resolve them. If aliases, plugins, or other project-specific settings are missing, configure the component dev server to provide what the component needs.

Does the first mount-only spec prove the component works?

It proves only that the component mounted in that test environment. Add assertions for the behavior the spec is intended to verify.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

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.