Implementation:Cypress io Cypress Mount Stub
| Knowledge Sources | |
|---|---|
| Domains | Component_Testing, Driver |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Concrete stub command in the Cypress driver that throws an error directing users to install the framework-specific mount package.
Description
The mount command in the driver package (packages/driver/src/cy/commands/actions/mount.ts) is a stub that throws an error when invoked. It exists as a placeholder to provide a helpful error message directing users to install the appropriate framework-specific mount package (cypress/react, cypress/vue, etc.). The actual mount implementations live in the npm/ directory packages.
Usage
This stub is registered as the default cy.mount command. When a user correctly configures component testing, their cypress/support/component.ts file will import the real mount from the framework package, overriding this stub via Cypress.Commands.add('mount', ...).
Code Reference
Source Location
- Repository: cypress-io/cypress
- File: packages/driver/src/cy/commands/actions/mount.ts
- Lines: L3-9
Signature
// The stub mount command (throws error directing to framework package)
Cypress.Commands.add('mount', () => {
throw new Error(
'cy.mount() requires a component testing framework-specific mount command. ' +
'Install cypress/react, cypress/vue, cypress/angular, or cypress/svelte.'
)
})
Import
// Users import from framework-specific packages, NOT the driver stub:
import { mount } from 'cypress/react' // React
import { mount } from 'cypress/vue' // Vue
import { mount } from 'cypress/angular' // Angular
import { mount } from 'cypress/svelte' // Svelte
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| component | ReactNode / VueComponent / Type<T> / SvelteComponent | Yes | The component to mount (type depends on framework) |
| options | MountOptions | No | Framework-specific mount options |
Outputs
| Name | Type | Description |
|---|---|---|
| Error | Error | Throws error directing to framework-specific mount package (stub behavior) |
Usage Examples
Setting Up Component Support
// cypress/support/component.ts
import { mount } from 'cypress/react'
Cypress.Commands.add('mount', mount)
// This overrides the driver stub with the real React mount