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> |
| 名称 | 类型 | 描述 |
| component | Component<Record<string, any>, Record<string, any>, any> | 要挂载的Svelte组件 |
| options | MountOptions (可选) | 用于自定义挂载组件的选项 |
示例
import Counter from './Counter.svelte'
import { mount } from 'cypress/svelte'
it('should render', () => {
mount(Counter, { props: { count: 42 } })
cy.get('button').contains(42)
})
接口
MountOptions
| 名称 | 类型 | 描述 |
| anchor | Element (可选) | |
| context | Map<any, any> (可选) | |
| intro | boolean (可选) | |
| log | boolean (可选) | |
| props | Record<string any> (可选) |
MountReturn
mount函数返回的类型
| 名称 | 类型 | 描述 |
| component | Record<string, any> |