Skip to main content
Cypress应用

Svelte API

方法

mount

import { mount } from 'cypress/svelte'
描述在Cypress浏览器中挂载Svelte组件
签名

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

返回值Cypress.Chainable<MountReturn>
mount 参数
名称类型描述
component

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

要挂载的Svelte组件
optionsMountOptions (可选)用于自定义挂载组件的选项

示例

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

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

接口

MountOptions

成员
名称类型描述
anchorElement (可选)
contextMap<any, any> (可选)
introboolean (可选)
logboolean (可选)
propsRecord<string any> (可选)

MountReturn

mount函数返回的类型

成员
名称类型描述
componentRecord<string, any>