Svelte API

Methods

mount

import { mount } from 'cypress/svelte'
Description Mounts a Svelte component inside the Cypress browser
Signature mount<T extends SvelteComponent>(Component: SvelteConstructor<T>, options?: MountOptions<T>): Cypress.Chainable<MountReturn<T>>;
Generic Param T The component type
Returns Cypress.Chainable<MountReturn>

Parameters

component
Description Svelte component being mounted
Type SvelteConstructor
options
Description options to customize the component being mounted
Type MountOptions<T> (optional)
Default undefined

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

import { MountOptions } from 'cypress/svelte'
Description Options to customize the component being mounted
Generic Param T The component type

Properties

anchor
Description
Type Element (optional)
Default undefined
context
Description
Type Map<any, any> (optional)
Default undefined
intro
Description
Type boolean (optional)
Default undefined
log
Description Log the mounting command into Cypress Command Log, true by default
Type boolean (optional)
Default true
props
Description props to pass into the component
Type Record<string any> (optional)
Default undefined

MountReturn

import { MountReturn } from 'cypress/svelte'
Description Type that the `mount` function returns
Generic Param T The component type

Properties

component
Description The instance of the component class
Type T