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
Description | Svelte component being mounted |
Type | SvelteConstructor |
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
Description | |
Type | Element (optional) |
Default | undefined |
Description | |
Type | Map<any, any> (optional) |
Default | undefined |
Description | |
Type | boolean (optional) |
Default | undefined |
Description | Log the mounting command into Cypress Command Log, true by default |
Type | boolean (optional) |
Default | true |
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
Description | The instance of the component class |
Type | T |