{
  "doc": {
    "id": "api/commands/mount",
    "title": "cy.mount()",
    "description": "Render a component in Cypress Component Testing with cy.mount(), a custom command you register in your component support file.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/mount.md",
    "version": "c4ad6f88c531de58221c73dd91a75af7138334b8",
    "updated_at": "2026-11-10T01:15:02.829Z",
    "headings": [
      {
        "id": "api/commands/mount#mount",
        "text": "mount",
        "level": 1
      },
      {
        "id": "api/commands/mount#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/mount#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/mount#yields",
        "text": "Yields",
        "level": 3
      },
      {
        "id": "api/commands/mount#create-a-new-cy-mount-command",
        "text": "Create a new cy.mount() command",
        "level": 2
      },
      {
        "id": "api/commands/mount#add-typescript-typings-for-cy-mount-commands",
        "text": "Add TypeScript typings for cy.mount() commands",
        "level": 2
      },
      {
        "id": "api/commands/mount#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/mount#use-cy-mount-in-a-component-test",
        "text": "Use cy.mount() in a component test",
        "level": 3
      },
      {
        "id": "api/commands/mount#remount-and-rerender-components-with-cy-mount",
        "text": "Remount and rerender components with cy.mount()",
        "level": 3
      },
      {
        "id": "api/commands/mount#load-global-styles-in-component-tests",
        "text": "Load global styles in component tests",
        "level": 3
      },
      {
        "id": "api/commands/mount#add-your-own-options-to-cy-mount",
        "text": "Add your own options to cy.mount()",
        "level": 3
      },
      {
        "id": "api/commands/mount#register-more-than-one-mount-command",
        "text": "Register more than one mount command",
        "level": 3
      },
      {
        "id": "api/commands/mount#additional-mount-command-examples",
        "text": "Additional mount command examples",
        "level": 2
      },
      {
        "id": "api/commands/mount#notes",
        "text": "Notes",
        "level": 2
      },
      {
        "id": "api/commands/mount#cy-mount-must-be-implemented-by-the-user",
        "text": "cy.mount() must be implemented by the user",
        "level": 3
      },
      {
        "id": "api/commands/mount#property-mount-does-not-exist-on-type-cy-cyeventemitter",
        "text": "Property 'mount' does not exist on type 'cy & CyEventEmitter'",
        "level": 3
      },
      {
        "id": "api/commands/mount#a-mounting-library-ends-up-in-your-end-to-end-tests",
        "text": "A mounting library ends up in your end-to-end tests",
        "level": 3
      },
      {
        "id": "api/commands/mount#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/mount#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/mount#syntax",
      "doc_id": "api/commands/mount",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\ncy.mount(component)\ncy.mount(component, options)\n```\n\n### Arguments\n\n**component**\n\nThe component to render, in the form your framework's `mount()` takes:\n\n*   Angular: a component class, or a template string\n*   React: a JSX element, such as `<Stepper />`\n*   Svelte: a Svelte component\n*   Vue: a Vue component\n\n**options _(Object)_**\n\nOptions for your framework's `mount()`, such as props, plus any options your custom command adds. Each framework's API page lists its options:\n\n*   [Angular API](/llm/markdown/app/component-testing/angular/api.md)\n*   [React API](/llm/markdown/app/component-testing/react/api.md)\n*   [Svelte API](/llm/markdown/app/component-testing/svelte/api.md)\n*   [Vue API](/llm/markdown/app/component-testing/vue/api.md)\n\n### Yields\n\n`cy.mount()` yields whatever your framework's `mount()` returns:\n\n| Framework | Yields | Use it to |\n| --- | --- | --- |\n| Angular | `{ component, fixture }` | Read the component instance, or work with its `ComponentFixture` |\n| React | `{ component, rerender }` | Rerender the component with new props (see [Remount and rerender](#Remount-and-rerender-components-with-cymount)) |\n| Svelte | `{ component }` | Call functions and read values the component exports |\n| Vue | `{ component, wrapper }` | Read the component instance, or use the Vue Test Utils wrapper's methods |\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 245
    },
    {
      "id": "api/commands/mount#arguments",
      "doc_id": "api/commands/mount",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**component**\n\nThe component to render, in the form your framework's `mount()` takes:\n\n*   Angular: a component class, or a template string\n*   React: a JSX element, such as `<Stepper />`\n*   Svelte: a Svelte component\n*   Vue: a Vue component\n\n**options _(Object)_**\n\nOptions for your framework's `mount()`, such as props, plus any options your custom command adds. Each framework's API page lists its options:\n\n*   [Angular API](/llm/markdown/app/component-testing/angular/api.md)\n*   [React API](/llm/markdown/app/component-testing/react/api.md)\n*   [Svelte API](/llm/markdown/app/component-testing/svelte/api.md)\n*   [Vue API](/llm/markdown/app/component-testing/vue/api.md)\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 104
    },
    {
      "id": "api/commands/mount#yields",
      "doc_id": "api/commands/mount",
      "heading": "Yields",
      "heading_level": 3,
      "content_markdown": "### Yields\n\n`cy.mount()` yields whatever your framework's `mount()` returns:\n\n| Framework | Yields | Use it to |\n| --- | --- | --- |\n| Angular | `{ component, fixture }` | Read the component instance, or work with its `ComponentFixture` |\n| React | `{ component, rerender }` | Rerender the component with new props (see [Remount and rerender](#Remount-and-rerender-components-with-cymount)) |\n| Svelte | `{ component }` | Call functions and read values the component exports |\n| Vue | `{ component, wrapper }` | Read the component instance, or use the Vue Test Utils wrapper's methods |\n",
      "section": "api",
      "anchors": [
        "yields"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 132
    },
    {
      "id": "api/commands/mount#create-a-new-cy-mount-command",
      "doc_id": "api/commands/mount",
      "heading": "Create a new cy.mount() command",
      "heading_level": 2,
      "content_markdown": "## Create a new `cy.mount()` command\n\nWhen you configure Component Testing through the Cypress App, Cypress scaffolds the command for you in `cypress/support/component.js` (or `cypress/support/component.ts`), so most projects start with a working `cy.mount()` that you can customize from there.\n\nWe recommend registering a custom `cy.mount()` command instead of importing the mount function from the mounting libraries in each spec. Doing so offers a few advantages:\n\n*   You don't need to import the mount function into every spec, since `cy.mount()` is available globally.\n*   You set up what every test needs in one place, such as wrapping a component in a [React context provider](https://react.dev/learn/passing-data-deeply-with-context) or adding [Vue plugins](https://vuejs.org/guide/reusability/plugins.html).\n\nTo use `cy.mount()`, add a custom command with [`Cypress.Commands.add()`](/llm/markdown/api/cypress-api/custom-commands.md) in your component support file. The file only loads for component tests, so your end-to-end tests don't bundle a mounting library they never use. Start from one of these examples:\n\n*   React\n*   Angular\n*   Vue\n*   Svelte\n\ncypress/support/component.js\n\n```\nimport { mount } from 'cypress/react'\n\nCypress.Commands.add('mount', (component, options) => {\n  // Rename this file to .jsx to wrap the component in providers:\n  // return mount(<MyProvider>{component}</MyProvider>, options)\n  return mount(component, options)\n})\n```\n\ncypress/support/component.js\n\n```\nimport { mount } from 'cypress/angular'\n\nCypress.Commands.add('mount', (component, config) => {\n  return mount(component, config)\n})\n```\n\ncypress/support/component.js\n\n```\nimport { mount } from 'cypress/vue'\n\nCypress.Commands.add('mount', (component, options = {}) => {\n  // Set up the options object\n  options.global = options.global || {}\n  options.global.stubs = options.global.stubs || {}\n  if (!Array.isArray(options.global.stubs)) {\n    options.global.stubs['transition'] = false\n  }\n  options.global.components = options.global.components || {}\n  options.global.plugins = options.global.plugins || []\n\n  // Add any global plugins\n  // options.global.plugins.push({\n  //   install(app) {\n  //     app.use(MyPlugin)\n  //   },\n  // })\n\n  // Add any global components\n  // options.global.components['Button'] = Button\n\n  return mount(component, options)\n})\n```\n\ncypress/support/component.js\n\n```\nimport { mount } from 'cypress/svelte'\n\nCypress.Commands.add('mount', (component, options) => {\n  return mount(component, options)\n})\n```\n",
      "section": "api",
      "anchors": [
        "create-a-new-cy-mount-command"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 403
    },
    {
      "id": "api/commands/mount#add-typescript-typings-for-cy-mount-commands",
      "doc_id": "api/commands/mount",
      "heading": "Add TypeScript typings for cy.mount() commands",
      "heading_level": 2,
      "content_markdown": "## Add TypeScript typings for `cy.mount()` commands\n\nWhen working in [TypeScript](/llm/markdown/app/tooling/typescript-support.md), your custom command needs typings for code completion and to avoid TypeScript errors. Add a `declare global` block that types `cy.mount()` to `cypress/support/component.ts`, which is where Cypress scaffolds the command. To make the typings available to any code in your project, put the block in a `cypress.d.ts` file in the root directory instead. Use this example as a starting point:\n\n*   React\n*   Angular\n*   Vue\n*   Svelte\n\ncypress.d.ts\n\n```\nimport { mount } from 'cypress/react'\n\ndeclare global {\n  namespace Cypress {\n    interface Chainable {\n      mount: typeof mount\n    }\n  }\n}\n```\n\ncypress.d.ts\n\n```\nimport { mount } from 'cypress/angular'\n\ndeclare global {\n  namespace Cypress {\n    interface Chainable {\n      mount: typeof mount\n    }\n  }\n}\n```\n\ncypress.d.ts\n\n```\nimport { mount } from 'cypress/vue'\n\ndeclare global {\n  namespace Cypress {\n    interface Chainable {\n      mount: typeof mount\n    }\n  }\n}\n```\n\ncypress.d.ts\n\n```\nimport { mount } from 'cypress/svelte'\n\ndeclare global {\n  namespace Cypress {\n    interface Chainable {\n      mount: typeof mount\n    }\n  }\n}\n```\n\nIf your specs can't find the types for your custom commands, add `cypress.d.ts` to the `include` array in each `tsconfig.json`:\n\ntsconfig.json\n\n```\n{\n  \"include\": [\"./src\", \"cypress.d.ts\"]\n}\n```\n",
      "section": "api",
      "anchors": [
        "add-typescript-typings-for-cy-mount-commands"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 271
    },
    {
      "id": "api/commands/mount#examples",
      "doc_id": "api/commands/mount",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### Use `cy.mount()` in a component test\n\nOnce you register the command, call `cy.mount()` from any component spec with the component and the options your framework's `mount()` accepts. Then query and assert on the rendered component the same way you would on a page, and use what `cy.mount()` [yields](#Yields) when you need the component itself:\n\n*   React\n*   Angular\n*   Vue\n*   Svelte\n\nStepper.cy.jsx\n\n```\nimport Stepper from './Stepper'\n\nit('starts the count at the initial value', () => {\n  cy.mount(<Stepper initial={5} />)\n  cy.get('[data-cy=counter]').should('have.text', '5')\n})\n```\n\nstepper.component.cy.ts\n\n```\nimport { StepperComponent } from './stepper.component'\n\nit('sets the count from componentProperties', () => {\n  cy.mount(StepperComponent, { componentProperties: { count: 5 } }).then(\n    ({ component }) => {\n      expect(component.count).to.equal(5)\n    }\n  )\n  cy.get('[data-cy=counter]').should('have.text', '5')\n})\n```\n\nStepper.cy.js\n\n```\nimport Stepper from './Stepper.vue'\n\nit('emits the new count when incremented', () => {\n  cy.mount(Stepper, { props: { initial: 5 } }).as('stepper')\n  cy.get('[data-cy=increment]').click()\n\n  cy.get('@stepper')\n    .its('wrapper')\n    .invoke('emitted', 'change')\n    .should('deep.equal', [[6]])\n})\n```\n\nStepper.cy.js\n\n```\nimport Stepper from './Stepper.svelte'\n\nit('resets the count through an exported function', () => {\n  cy.mount(Stepper, { props: { initial: 5 } }).then(({ component }) => {\n    component.reset()\n  })\n  cy.get('[data-cy=counter]').should('have.text', '0')\n})\n```\n\n### Remount and rerender components with `cy.mount()`\n\nCalling `cy.mount()` again in the same test unmounts the previous component first, so each mount starts with fresh state. Every framework's `mount()` behaves this way.\n\nIn React, use the `rerender()` function that `cy.mount()` yields to update the props of the component that's already mounted. Unlike a second `cy.mount()`, it keeps the component's state:\n\n*   React\n\nStepper.cy.jsx\n\n```\nimport Stepper from './Stepper'\n\nit('keeps its count when rerendered with a new label', () => {\n  cy.mount(<Stepper label=\"Count\" />).as('stepper')\n  cy.get('[data-cy=increment]').click()\n\n  cy.get('@stepper').then(({ rerender }) => {\n    rerender(<Stepper label=\"Total\" />)\n  })\n\n  cy.get('[data-cy=label]').should('have.text', 'Total')\n  cy.get('[data-cy=counter]').should('have.text', '1')\n})\n\nit('starts over when mounted again', () => {\n  cy.mount(<Stepper />)\n  cy.get('[data-cy=increment]').click()\n\n  cy.mount(<Stepper />)\n  cy.get('[data-cy=counter]').should('have.text', '0')\n})\n```\n\n### Load global styles in component tests\n\nComponent tests don't run your app's entry file, so the global styles it imports, such as a CSS reset, fonts, or a CSS framework, are missing and components can look unstyled. Import those styles in your component support file so they load for every component test:\n\ncypress/support/component.js\n\n```\n// Global styles that your app's entry file imports\nimport '../../src/styles/global.css'\n\nimport { mount } from 'cypress/react'\n\nCypress.Commands.add('mount', mount)\n```\n\nFor CSS libraries, component HTML files, and other styling setups, see [Styling components](/llm/markdown/app/component-testing/styling-components.md).\n\n### Add your own options to `cy.mount()`\n\nA custom command can accept options of its own, such as which theme to render a component in. Once it does, `mount: typeof mount` no longer describes the command, so declare its signature yourself. Build it from `Parameters<typeof mount>` and `ReturnType<typeof mount>` to keep the framework's own options and yield. This example wraps the component in JSX, so it goes in `cypress/support/component.tsx`: rename the scaffolded `component.ts`, and Cypress still finds it.\n\ncypress/support/component.tsx\n\n```\nimport { mount } from 'cypress/react'\nimport { ThemeProvider } from '../../src/ThemeProvider'\n\ntype MountParams = Parameters<typeof mount>\ntype MountOptions = NonNullable<MountParams[1]> & { theme?: 'light' | 'dark' }\n\ndeclare global {\n  namespace Cypress {\n    interface Chainable {\n      mount(\n        component: MountParams[0],\n        options?: MountOptions\n      ): ReturnType<typeof mount>\n    }\n  }\n}\n\nCypress.Commands.add('mount', (component, options = {}) => {\n  const { theme = 'light', ...mountOptions } = options\n\n  return mount(\n    <ThemeProvider theme={theme}>{component}</ThemeProvider>,\n    mountOptions\n  )\n})\n```\n\nButton.cy.tsx\n\n```\nimport { Button } from './Button'\n\nit('renders in the dark theme', () => {\n  cy.mount(<Button>Save</Button>, { theme: 'dark' })\n  cy.get('button').should('have.class', 'dark')\n})\n```\n\nThe [React Router](/llm/markdown/app/component-testing/react/examples.md#React-Router), [Redux](/llm/markdown/app/component-testing/react/examples.md#Redux), and [Vue Router](/llm/markdown/app/component-testing/vue/examples.md#Vue-Router) examples follow the same approach.\n\n### Register more than one mount command\n\nWhen only some components need extra setup, register a second command next to `cy.mount()` instead of adding options to it. `cy.mount()` stays a plain passthrough, and each spec's name for the command says what setup it gets. Like the previous example, this one uses JSX:\n\ncypress/support/component.tsx\n\n```\nimport { mount } from 'cypress/react'\nimport { AuthProvider, type User } from '../../src/AuthProvider'\n\ntype MountParams = Parameters<typeof mount>\n\ndeclare global {\n  namespace Cypress {\n    interface Chainable {\n      mount: typeof mount\n      mountSignedIn(\n        component: MountParams[0],\n        user: User,\n        options?: MountParams[1]\n      ): ReturnType<typeof mount>\n    }\n  }\n}\n\nCypress.Commands.add('mount', mount)\n\nCypress.Commands.add('mountSignedIn', (component, user, options) => {\n  return mount(<AuthProvider user={user}>{component}</AuthProvider>, options)\n})\n```\n\nAccountMenu.cy.tsx\n\n```\nimport { AccountMenu } from './AccountMenu'\n\nit('shows a sign-in link to signed-out visitors', () => {\n  cy.mount(<AccountMenu />)\n  cy.contains('a', 'Sign in')\n})\n\nit('greets a signed-in user by name', () => {\n  cy.mountSignedIn(<AccountMenu />, { name: 'Ada' })\n  cy.contains('Signed in as Ada')\n})\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 985
    },
    {
      "id": "api/commands/mount#use-cy-mount-in-a-component-test",
      "doc_id": "api/commands/mount",
      "heading": "Use cy.mount() in a component test",
      "heading_level": 3,
      "content_markdown": "### Use `cy.mount()` in a component test\n\nOnce you register the command, call `cy.mount()` from any component spec with the component and the options your framework's `mount()` accepts. Then query and assert on the rendered component the same way you would on a page, and use what `cy.mount()` [yields](#Yields) when you need the component itself:\n\n*   React\n*   Angular\n*   Vue\n*   Svelte\n\nStepper.cy.jsx\n\n```\nimport Stepper from './Stepper'\n\nit('starts the count at the initial value', () => {\n  cy.mount(<Stepper initial={5} />)\n  cy.get('[data-cy=counter]').should('have.text', '5')\n})\n```\n\nstepper.component.cy.ts\n\n```\nimport { StepperComponent } from './stepper.component'\n\nit('sets the count from componentProperties', () => {\n  cy.mount(StepperComponent, { componentProperties: { count: 5 } }).then(\n    ({ component }) => {\n      expect(component.count).to.equal(5)\n    }\n  )\n  cy.get('[data-cy=counter]').should('have.text', '5')\n})\n```\n\nStepper.cy.js\n\n```\nimport Stepper from './Stepper.vue'\n\nit('emits the new count when incremented', () => {\n  cy.mount(Stepper, { props: { initial: 5 } }).as('stepper')\n  cy.get('[data-cy=increment]').click()\n\n  cy.get('@stepper')\n    .its('wrapper')\n    .invoke('emitted', 'change')\n    .should('deep.equal', [[6]])\n})\n```\n\nStepper.cy.js\n\n```\nimport Stepper from './Stepper.svelte'\n\nit('resets the count through an exported function', () => {\n  cy.mount(Stepper, { props: { initial: 5 } }).then(({ component }) => {\n    component.reset()\n  })\n  cy.get('[data-cy=counter]').should('have.text', '0')\n})\n```\n",
      "section": "api",
      "anchors": [
        "use-cy-mount-in-a-component-test"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 251
    },
    {
      "id": "api/commands/mount#remount-and-rerender-components-with-cy-mount",
      "doc_id": "api/commands/mount",
      "heading": "Remount and rerender components with cy.mount()",
      "heading_level": 3,
      "content_markdown": "### Remount and rerender components with `cy.mount()`\n\nCalling `cy.mount()` again in the same test unmounts the previous component first, so each mount starts with fresh state. Every framework's `mount()` behaves this way.\n\nIn React, use the `rerender()` function that `cy.mount()` yields to update the props of the component that's already mounted. Unlike a second `cy.mount()`, it keeps the component's state:\n\n*   React\n\nStepper.cy.jsx\n\n```\nimport Stepper from './Stepper'\n\nit('keeps its count when rerendered with a new label', () => {\n  cy.mount(<Stepper label=\"Count\" />).as('stepper')\n  cy.get('[data-cy=increment]').click()\n\n  cy.get('@stepper').then(({ rerender }) => {\n    rerender(<Stepper label=\"Total\" />)\n  })\n\n  cy.get('[data-cy=label]').should('have.text', 'Total')\n  cy.get('[data-cy=counter]').should('have.text', '1')\n})\n\nit('starts over when mounted again', () => {\n  cy.mount(<Stepper />)\n  cy.get('[data-cy=increment]').click()\n\n  cy.mount(<Stepper />)\n  cy.get('[data-cy=counter]').should('have.text', '0')\n})\n```\n",
      "section": "api",
      "anchors": [
        "remount-and-rerender-components-with-cy-mount"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 153
    },
    {
      "id": "api/commands/mount#load-global-styles-in-component-tests",
      "doc_id": "api/commands/mount",
      "heading": "Load global styles in component tests",
      "heading_level": 3,
      "content_markdown": "### Load global styles in component tests\n\nComponent tests don't run your app's entry file, so the global styles it imports, such as a CSS reset, fonts, or a CSS framework, are missing and components can look unstyled. Import those styles in your component support file so they load for every component test:\n\ncypress/support/component.js\n\n```\n// Global styles that your app's entry file imports\nimport '../../src/styles/global.css'\n\nimport { mount } from 'cypress/react'\n\nCypress.Commands.add('mount', mount)\n```\n\nFor CSS libraries, component HTML files, and other styling setups, see [Styling components](/llm/markdown/app/component-testing/styling-components.md).\n",
      "section": "api",
      "anchors": [
        "load-global-styles-in-component-tests"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 117
    },
    {
      "id": "api/commands/mount#add-your-own-options-to-cy-mount",
      "doc_id": "api/commands/mount",
      "heading": "Add your own options to cy.mount()",
      "heading_level": 3,
      "content_markdown": "### Add your own options to `cy.mount()`\n\nA custom command can accept options of its own, such as which theme to render a component in. Once it does, `mount: typeof mount` no longer describes the command, so declare its signature yourself. Build it from `Parameters<typeof mount>` and `ReturnType<typeof mount>` to keep the framework's own options and yield. This example wraps the component in JSX, so it goes in `cypress/support/component.tsx`: rename the scaffolded `component.ts`, and Cypress still finds it.\n\ncypress/support/component.tsx\n\n```\nimport { mount } from 'cypress/react'\nimport { ThemeProvider } from '../../src/ThemeProvider'\n\ntype MountParams = Parameters<typeof mount>\ntype MountOptions = NonNullable<MountParams[1]> & { theme?: 'light' | 'dark' }\n\ndeclare global {\n  namespace Cypress {\n    interface Chainable {\n      mount(\n        component: MountParams[0],\n        options?: MountOptions\n      ): ReturnType<typeof mount>\n    }\n  }\n}\n\nCypress.Commands.add('mount', (component, options = {}) => {\n  const { theme = 'light', ...mountOptions } = options\n\n  return mount(\n    <ThemeProvider theme={theme}>{component}</ThemeProvider>,\n    mountOptions\n  )\n})\n```\n\nButton.cy.tsx\n\n```\nimport { Button } from './Button'\n\nit('renders in the dark theme', () => {\n  cy.mount(<Button>Save</Button>, { theme: 'dark' })\n  cy.get('button').should('have.class', 'dark')\n})\n```\n\nThe [React Router](/llm/markdown/app/component-testing/react/examples.md#React-Router), [Redux](/llm/markdown/app/component-testing/react/examples.md#Redux), and [Vue Router](/llm/markdown/app/component-testing/vue/examples.md#Vue-Router) examples follow the same approach.\n",
      "section": "api",
      "anchors": [
        "add-your-own-options-to-cy-mount"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 252
    },
    {
      "id": "api/commands/mount#register-more-than-one-mount-command",
      "doc_id": "api/commands/mount",
      "heading": "Register more than one mount command",
      "heading_level": 3,
      "content_markdown": "### Register more than one mount command\n\nWhen only some components need extra setup, register a second command next to `cy.mount()` instead of adding options to it. `cy.mount()` stays a plain passthrough, and each spec's name for the command says what setup it gets. Like the previous example, this one uses JSX:\n\ncypress/support/component.tsx\n\n```\nimport { mount } from 'cypress/react'\nimport { AuthProvider, type User } from '../../src/AuthProvider'\n\ntype MountParams = Parameters<typeof mount>\n\ndeclare global {\n  namespace Cypress {\n    interface Chainable {\n      mount: typeof mount\n      mountSignedIn(\n        component: MountParams[0],\n        user: User,\n        options?: MountParams[1]\n      ): ReturnType<typeof mount>\n    }\n  }\n}\n\nCypress.Commands.add('mount', mount)\n\nCypress.Commands.add('mountSignedIn', (component, user, options) => {\n  return mount(<AuthProvider user={user}>{component}</AuthProvider>, options)\n})\n```\n\nAccountMenu.cy.tsx\n\n```\nimport { AccountMenu } from './AccountMenu'\n\nit('shows a sign-in link to signed-out visitors', () => {\n  cy.mount(<AccountMenu />)\n  cy.contains('a', 'Sign in')\n})\n\nit('greets a signed-in user by name', () => {\n  cy.mountSignedIn(<AccountMenu />, { name: 'Ada' })\n  cy.contains('Signed in as Ada')\n})\n```\n",
      "section": "api",
      "anchors": [
        "register-more-than-one-mount-command"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 209
    },
    {
      "id": "api/commands/mount#additional-mount-command-examples",
      "doc_id": "api/commands/mount",
      "heading": "Additional mount command examples",
      "heading_level": 2,
      "content_markdown": "## Additional mount command examples\n\nThe framework example pages cover more customized mount commands, such as routers, state management, and app-wide providers:\n\n*   [Angular examples](/llm/markdown/app/component-testing/angular/examples.md)\n*   [React examples](/llm/markdown/app/component-testing/react/examples.md)\n*   [Svelte examples](/llm/markdown/app/component-testing/svelte/examples.md)\n*   [Vue examples](/llm/markdown/app/component-testing/vue/examples.md)\n",
      "section": "api",
      "anchors": [
        "additional-mount-command-examples"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 45
    },
    {
      "id": "api/commands/mount#notes",
      "doc_id": "api/commands/mount",
      "heading": "Notes",
      "heading_level": 2,
      "content_markdown": "## Notes\n\n### `cy.mount()` must be implemented by the user\n\nCalling `cy.mount()` before any file registers it fails with this error:\n\n```\n`cy.mount()` must be implemented by the user. There are\nfull instructions for doing so at the following location.\n\nhttps://on.cypress.io/mount\n```\n\nIn the Cypress App, the error appears on the failed test in the Command Log:\n\nComponent tests never loaded a file that registers the command. Check that:\n\n*   `Cypress.Commands.add('mount', ...)` is in `cypress/support/component.js` (or `.jsx`, `.ts`, `.tsx`), or in a file that it imports\n*   The [`supportFile`](/llm/markdown/app/references/configuration.md#component) option under `component` in your Cypress configuration points at that file and isn't set to `false`\n\n### Property 'mount' does not exist on type 'cy & CyEventEmitter'\n\nTypeScript can't see the typings for your command. Add the `declare global` block from [the typings section](#Add-TypeScript-typings-for-cymount-commands) to your support file or `cypress.d.ts`, and make sure every `tsconfig.json` that covers your specs includes that file.\n\n### A mounting library ends up in your end-to-end tests\n\nThe end-to-end and component support files Cypress scaffolds both import `cypress/support/commands.js`, so a `cy.mount()` registered there bundles your framework's mounting library into every end-to-end spec. Move the registration to `cypress/support/component.js`.\n",
      "section": "api",
      "anchors": [
        "notes"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 255
    },
    {
      "id": "api/commands/mount#cy-mount-must-be-implemented-by-the-user",
      "doc_id": "api/commands/mount",
      "heading": "cy.mount() must be implemented by the user",
      "heading_level": 3,
      "content_markdown": "### `cy.mount()` must be implemented by the user\n\nCalling `cy.mount()` before any file registers it fails with this error:\n\n```\n`cy.mount()` must be implemented by the user. There are\nfull instructions for doing so at the following location.\n\nhttps://on.cypress.io/mount\n```\n\nIn the Cypress App, the error appears on the failed test in the Command Log:\n\nComponent tests never loaded a file that registers the command. Check that:\n\n*   `Cypress.Commands.add('mount', ...)` is in `cypress/support/component.js` (or `.jsx`, `.ts`, `.tsx`), or in a file that it imports\n*   The [`supportFile`](/llm/markdown/app/references/configuration.md#component) option under `component` in your Cypress configuration points at that file and isn't set to `false`\n",
      "section": "api",
      "anchors": [
        "cy-mount-must-be-implemented-by-the-user"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 137
    },
    {
      "id": "api/commands/mount#property-mount-does-not-exist-on-type-cy-cyeventemitter",
      "doc_id": "api/commands/mount",
      "heading": "Property 'mount' does not exist on type 'cy & CyEventEmitter'",
      "heading_level": 3,
      "content_markdown": "### Property 'mount' does not exist on type 'cy & CyEventEmitter'\n\nTypeScript can't see the typings for your command. Add the `declare global` block from [the typings section](#Add-TypeScript-typings-for-cymount-commands) to your support file or `cypress.d.ts`, and make sure every `tsconfig.json` that covers your specs includes that file.\n",
      "section": "api",
      "anchors": [
        "property-mount-does-not-exist-on-type-cy-cyeventemitter"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 61
    },
    {
      "id": "api/commands/mount#a-mounting-library-ends-up-in-your-end-to-end-tests",
      "doc_id": "api/commands/mount",
      "heading": "A mounting library ends up in your end-to-end tests",
      "heading_level": 3,
      "content_markdown": "### A mounting library ends up in your end-to-end tests\n\nThe end-to-end and component support files Cypress scaffolds both import `cypress/support/commands.js`, so a `cy.mount()` registered there bundles your framework's mounting library into every end-to-end spec. Move the registration to `cypress/support/component.js`.\n",
      "section": "api",
      "anchors": [
        "a-mounting-library-ends-up-in-your-end-to-end-tests"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 53
    },
    {
      "id": "api/commands/mount#command-log",
      "doc_id": "api/commands/mount",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\nMount a component and assert on its text, as in the React example from [Use `cy.mount()` in a component test](#Use-cymount-in-a-component-test):\n\nStepper.cy.jsx\n\n```\ncy.mount(<Stepper initial={5} />)\ncy.get('[data-cy=counter]').should('have.text', '5')\n```\n\nThe commands above display in the Command Log as:\n\nWhether `cy.mount()` adds a `mount` row depends on your framework's mounting library:\n\n*   Angular always logs the row, with the component's class name, or `Component` when you mount a template string.\n*   React and Vue log the row by default. Pass `log: false` in the options to leave it out. In React, `rerender()` adds a `rerender` row the same way.\n*   Svelte leaves the row out by default, since Svelte 5 components don't expose a useful name. Pass `log: true` in the options to show it.\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 168
    },
    {
      "id": "api/commands/mount#see-also",
      "doc_id": "api/commands/mount",
      "heading": "See also",
      "heading_level": 2,
      "content_markdown": "## See also\n\n*   [`Cypress.Commands.add()`](/llm/markdown/api/cypress-api/custom-commands.md)\n*   [Angular API](/llm/markdown/app/component-testing/angular/api.md) - `cypress/angular` mount options and yields\n*   [React API](/llm/markdown/app/component-testing/react/api.md) - `cypress/react` mount options and yields\n*   [Svelte API](/llm/markdown/app/component-testing/svelte/api.md) - `cypress/svelte` mount options and yields\n*   [Vue API](/llm/markdown/app/component-testing/vue/api.md) - `cypress/vue` mount options and yields\n",
      "section": "api",
      "anchors": [
        "see-also"
      ],
      "path": "/llm/json/chunked/api/commands/mount.json",
      "token_estimate": 55
    }
  ]
}