Skip to main content
Cypress App

Svelte API

Methods

mount

import { mount } from 'cypress/svelte'
DescriptionMounts a Svelte component inside the Cypress browser
Signature

mount(Component: Component<Record<string, any>, Record<string, any>, any>, options?: MountOptions): Cypress.Chainable<MountReturn>

ReturnsCypress.Chainable<MountReturn>
mount Parameters
NameTypeDescription
component

Component<Record<string, any>, Record<string, any>, any>

Svelte component being mounted
optionsMountOptions (optional)options to customize the component being mounted

Example

import Counter from './Counter.svelte'
import { mount } from 'cypress/svelte'

it('should render', () => {
mount(Counter, { props: { count: 42 } })
cy.get('button').contains(42)
})

Interfaces

MountOptions

members
NameTypeDescription
anchorElement (optional)
contextMap<any, any> (optional)
introboolean (optional)
logboolean (optional)
propsRecord<string any> (optional)

MountReturn

Type that the mount function yields

members
NameTypeDescription
componentRecord<string, any>