# Cypress Documentation
# Source: https://raw.githubusercontent.com/cypress-io/cypress-documentation/main/docs/app/component-testing/svelte/api.mdx
# Path: docs/app/component-testing/svelte/api.mdx

---
title: Svelte API
description: API for mounting Svelte components in Cypress tests.
sidebar_position: 40
sidebar_label: API
---

<ProductHeading product="app" />

# Svelte API

## Methods

### mount

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

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

<table class="api-table">
  <caption>mount Parameters</caption>
  <thead>
    <td>Name</td>
    <td>Type</td>
    <td>Description</td>
  </thead>
  <tr>
    <td>component</td>
    <td>
      Component&lt;Record&lt;string, any&gt;, Record&lt;string, any&gt;, any&gt;
    </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>
</table>

#### Example

```js
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 class="api-table">
  <caption>members</caption>
  <thead>
    <td>Name</td>
    <td>Type</td>
    <td>Description</td>
  </thead>
  <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>
</table>

### MountReturn

Type that the `mount` function yields

<table class="api-table">
  <caption>members</caption>
  <thead>
    <td>Name</td>
    <td>Type</td>
    <td>Description</td>
  </thead>
  <tr>
    <td>component</td>
    <td>Record&lt;string, any&gt;</td>
    <td></td>
  </tr>
</table>