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 DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk5 min

How to Test Vue.js Apps with Cypress

A practical guide to testing Vue components with Cypress in a real browser, from setup and a first interaction test to plugins, Nuxt, and troubleshooting.

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.

Use Cypress Component Testing to mount a Vue component in a real browser, then drive its rendered controls and assert on the behavior a user can observe. Choose end-to-end (E2E) testing instead when the behavior you need to verify depends on the running application, such as routing or integration across features. Cypress’s current Vue component-testing guide targets Vue 3+ with Vite 8.x or Webpack 5+; check its compatibility guidance because supported versions can change.

Choose component testing or E2E testing

Question Component testing E2E testing
What runs? An individual component mounted in a real browser in Cypress’s test environment. The application as a whole in a browser.
What must be set up? The component and any plugins, global components, or hierarchy it depends on. The running application and the environment needed for the complete workflow.
What question does it answer? Does this UI respond correctly to its props and user actions? Does the integrated application work from the user’s entry point?

Cypress describes component tests as rendering components directly in a real browser rather than a simulated DOM. See its component testing introduction and its explanation of E2E and component testing. These approaches cover different scopes; choose according to the claim your test needs to verify.

As an Amazon Associate I earn from qualifying purchases.

Install Cypress and configure Vue component testing

  1. Install Cypress as a development dependency using your package manager. For npm, run npm install --save-dev cypress.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  2. Open Cypress with npx cypress open and follow its Launchpad to configure Component Testing.

  3. In the Cypress component configuration, set the framework to Vue and choose the bundler your project uses. The configuration uses framework: 'vue' with bundler: 'vite' or bundler: 'webpack'.

  4. Confirm the versions supported by the Cypress Vue component-testing guide before relying on a particular combination. The guide currently identifies Vue 3+, Vite 8.x, and Webpack 5+.

Cypress’s component dev server compiles the test spec and support files with the app’s development transforms, then serves the compiled files to Cypress. Consequently, bundler settings can affect whether a component mounts: aliases, CSS processing, and other transforms used by the app may also need to be represented in component-test configuration. See Cypress’s component framework configuration guide.

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

Write a first test for a Vue component

Cypress’s Vue API exports mount from cypress/vue. In a component spec, the convenient form is cy.mount(), registered as a Cypress command in the component support file. Import the component, mount it, interact with its rendered UI, and assert on the result.

For example, if Stepper.vue accepts a count prop, emits an update event, and renders a button labelled “Increment,” this test checks that a click emits the updated value:

import Stepper from './Stepper.vue'

describe('Stepper', () => {
  it('emits the updated count when incremented', () => {
    const onUpdate = cy.spy().as('onUpdate')

    cy.mount(Stepper, {
      props: {
        count: 3,
        onUpdate,
      },
    })

    cy.contains('button', 'Increment').click()
    cy.get('@onUpdate').should('have.been.calledWith', 4)
  })
})

The example follows Cypress’s documented pattern of passing a prop, attaching a spy to an event prop, clicking a control, and asserting the value received. Adapt the prop, event handler, and accessible control query to the component’s actual interface. See the Vue API and Vue component examples.

Register shared plugins and app-level setup

A component mounted by itself does not automatically receive every plugin, global component, or parent wrapper from your application. If many specs need the same setup, customize the mount command in the component support file so tests can mount components consistently.

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

Cypress’s Vue examples demonstrate setting up Pinia, Vue I18n, Vue Router with memory history, Vuex, global components, and Vuetify’s VApp hierarchy. Reproduce only the application context the component needs; a component that depends on a router or Vuetify layout may not behave meaningfully without it. For Vuex, create a store for each test to prevent state changes from leaking into other tests. The official Vue examples show these setup patterns.

Nuxt projects need explicit configuration

Cypress does not read nuxt.config and has no dedicated Nuxt framework definition for component testing. When mounting a component on its own, Nuxt aliases such as ~ and @, as well as Nuxt auto-imports, are therefore not automatically available. Configure the needed aliases and transforms for the Vue/Vite component path, and explicitly provide imports or plugins the component relies on. See the Cypress Vue overview.

Or skip the browser setup

If you need a screenshot of a Vue page rather than an interactive Cypress test, ScreenshotNeo offers a one-request website screenshot API. It does not replace Cypress assertions or component tests; it captures a page as an image or PDF. The call below returns a WebP screenshot of Stripe; change the target URL to the page you want to capture.

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. Before capture, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; these steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. An 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.

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

Sign up for ScreenshotNeo to get 1,000 free screenshots a month with no card.

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

Troubleshoot common component-test failures

  • The component fails to compile or mount: Check that the Vue, bundler, and Cypress component configuration match the project, then inspect bundler transforms and aliases. Cypress compiles component specs through the configured dev server, so app build settings do not necessarily carry over automatically.

  • An import using ~ or @ fails in Nuxt: Configure that alias for the component-test bundler and explicitly supply imports or plugins that Nuxt would otherwise provide automatically.

  • A component cannot find a plugin or global component: Register the required plugin or global component in the mount setup, or add the parent wrapper the component expects. Cypress’s examples cover common integrations including Pinia, Vue I18n, Vue Router, Vuex, and Vuetify.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • A test passes alone but fails after another test: Avoid sharing mutable store state across tests. Cypress specifically recommends initializing Vuex state per test to prevent changes from leaking.

  • An assertion does not observe the expected event: Verify that the test passes the handler through the correct event prop and that the control interaction matches the component’s rendered UI. Assert on the value emitted after the user action, as in Cypress’s Vue examples.

Keep tests focused and reliable

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 *

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
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.