/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */ // noinspection ES6PreferShortImport // *********************************************************** // This example support/component.ts is processed and // loaded automatically before your test files. // // This is a great place to put global configuration and // behavior that modifies Cypress. // // You can change the location of this file or turn off // automatically serving support files with the // 'supportFile' configuration option. // // You can read more here: // https://on.cypress.io/configuration // *********************************************************** import './commands' import type { StyleOptions } from '@cypress/mount-utils' import type { MountingOptions } from '@vue/test-utils' import { mount } from 'cypress/vue' import registerGlobalComponents from 'src/plugins/global-components' import { routes } from 'src/router' import type { ComponentOptionsWithArrayProps, ComponentOptionsWithObjectProps, ComponentOptionsWithoutProps, ComponentPropsOptions, FunctionalComponent, DefineComponent, ExtractDefaultPropTypes, MethodOptions, AllowedComponentProps, ComponentCustomProps, VNodeProps, ComponentOptionsMixin, ComputedOptions, EmitsOptions, ExtractPropTypes, App, } from 'vue' import type { Router } from 'vue-router' import { createMemoryHistory, createRouter } from 'vue-router' type PublicProps = VNodeProps & AllowedComponentProps & ComponentCustomProps type RouterOptions = { router?: Router } export declare type CyMountOptions = & Omit, 'attachTo'> & { log?: boolean } & Partial & RouterOptions interface Mount { (originalComponent: { new(...args: any[]): V registerHooks(keys: string[]): void }, options?: MountingOptions): Cypress.Chainable (originalComponent: { new(...args: any[]): V props(Props: P): any registerHooks(keys: string[]): void }, options?: CyMountOptions

): Cypress.Chainable (originalComponent: FunctionalComponent, options?: CyMountOptions): Cypress.Chainable , EE extends string = string, PP = PublicProps, Props = Readonly>, Defaults = ExtractDefaultPropTypes>(component: DefineComponent, options?: CyMountOptions & Omit, D>): Cypress.Chainable (componentOptions: ComponentOptionsWithoutProps, options?: CyMountOptions): Cypress.Chainable = {}, E extends EmitsOptions = Record, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, EE extends string = string, Props extends Readonly<{ [key in PropNames]?: any; }> = Readonly<{ [key in PropNames]?: any; }>>(componentOptions: ComponentOptionsWithArrayProps, options?: CyMountOptions): Cypress.Chainable , RawBindings, D, C extends ComputedOptions = {}, M extends Record = {}, E extends EmitsOptions = Record, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, EE extends string = string>(componentOptions: ComponentOptionsWithObjectProps, options?: CyMountOptions & PublicProps, D>): Cypress.Chainable } type MountParams = Parameters declare global { namespace Cypress { // noinspection JSUnusedGlobalSymbols interface Chainable { mount: Mount } } } Cypress.Commands.add('mount', (component: MountParams[0], options: MountParams[1] = {}) => { options.global = options.global || {} options.global.plugins = options.global.plugins || [] if (!options.router) { options.router = createRouter({ routes, history: createMemoryHistory(), }) } options.global.plugins.push({ install (app: App) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion app.use(options.router!) }, }, { install (app: App) { registerGlobalComponents(app) }, }) return mount(component as any, options) })