---
id: app/write-tests/component-testing/svelte/api
title: Svelte API
description: API for mounting Svelte components in Cypress tests.
section: app
source_path: docs/app/write-tests/component-testing/svelte/api.mdx
version: 2069658b67bb86b8923569761b9bda5eebc57aff
updated_at: '2026-08-25T16:55:04.655Z'
---
# Svelte API

The `cypress/svelte` module provides the following methods and interfaces for mounting and testing Svelte components.

## mount

```
import { mount } from 'cypress/svelte'
```

<table><tbody><tr><td>Description</td><td>Mounts a Svelte component inside the Cypress browser</td></tr><tr><td>Signature</td><td><p>mount(Component: Component&lt;Record&lt;string, any&gt;, Record&lt;string, any&gt;, any&gt;, options?: MountOptions): Cypress.Chainable&lt;MountReturn&gt;</p></td></tr><tr><td>Returns</td><td>Cypress.Chainable&lt;MountReturn&gt;</td></tr></tbody></table>

<table><caption>mount Parameters</caption><thead></thead><tbody><tr><td>Name</td><td>Type</td><td>Description</td></tr><tr><td>component</td><td><p>Component&lt;Record&lt;string, any&gt;, Record&lt;string, any&gt;, any&gt;</p></td><td>Svelte component being mounted</td></tr><tr><td>options</td><td>MountOptions (optional)</td><td>options to customize the component being mounted</td></tr></tbody></table>

### 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

<table><caption>members</caption><thead></thead><tbody><tr><td>Name</td><td>Type</td><td>Description</td></tr><tr><td>anchor</td><td>Element (optional)</td><td></td></tr><tr><td>context</td><td>Map&lt;any, any&gt; (optional)</td><td></td></tr><tr><td>intro</td><td>boolean (optional)</td><td></td></tr><tr><td>log</td><td>boolean (optional)</td><td></td></tr><tr><td>props</td><td>Record&lt;string any&gt; (optional)</td><td></td></tr></tbody></table>

### MountReturn

Type that the `mount` function yields

<table><caption>members</caption><thead></thead><tbody><tr><td>Name</td><td>Type</td><td>Description</td></tr><tr><td>component</td><td>Record&lt;string, any&gt;</td><td></td></tr></tbody></table>
