Skip to main content

Svelte API

Methods​

mount​

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

mount<T extends SvelteComponent>(Component: SvelteConstructor<T>, options?: MountOptions<T>): Cypress.Chainable<MountReturn<T>>

Generic Param TThe component type
ReturnsCypress.Chainable<MountReturn>
mount Parameters
NameTypeDescription
componentSvelteConstructor<T>Svelte component being mounted
optionsMountOptions<T> (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
componentT