///
import Vue, { ComponentOptions as ComponentOptions$1, FunctionalComponentOptions, Component } from 'vue';
type Prop = { (): T } | { new(...args: never[]): T & object } | { new(...args: string[]): Function }
type PropType = Prop | Prop[];
type PropValidator = PropOptions | PropType;
interface PropOptions {
type?: PropType;
required?: boolean;
default?: T | null | undefined | (() => T | null | undefined);
validator?(value: T): boolean;
}
type RecordPropsDefinition = {
[K in keyof T]: PropValidator
}
type ArrayPropsDefinition = (keyof T)[];
type PropsDefinition = ArrayPropsDefinition | RecordPropsDefinition;
type DefaultProps = Record;
/**
* Utility type to declare an extended Vue constructor
*/
type VueClass = (new (...args: any[]) => V) & typeof Vue
/**
* Utility type for a selector
*/
type Selector = string | Component
/**
* Utility type for ref options object that can be used as a Selector
*/
type RefSelector = {
ref: string
}
/**
* Utility type for name options object that can be used as a Selector
*/
type NameSelector = {
name: string
}
/**
* Base class of Wrapper and WrapperArray
* It has common methods on both Wrapper and WrapperArray
*/
interface BaseWrapper {
contains (selector: Selector): boolean
exists (): boolean
isVisible (): boolean
attributes(): { [name: string]: string }
attributes(key: string): string | void
classes(): Array
classes(className: string): boolean
props(): { [name: string]: any }
props(key: string): any | void
overview(): void
is (selector: Selector): boolean
isEmpty (): boolean
isVueInstance (): boolean
setData (data: object): Promise | void
setMethods (data: object): void
setProps (props: object): Promise | void
setValue (value: any): Promise | void
setChecked (checked?: boolean): Promise | void
setSelected (): Promise | void
trigger (eventName: string, options?: object): Promise | void
destroy (): void
selector: Selector | void
}
interface Wrapper extends BaseWrapper {
readonly vm: V
readonly element: el
readonly options: WrapperOptions
get (selector: VueClass): Wrapper
get (selector: ComponentOptions$1): Wrapper
get>(selector: FunctionalComponentOptions): Wrapper
get(selector: string): Wrapper
get (selector: RefSelector): Wrapper
get (selector: NameSelector): Wrapper
getComponent (selector: VueClass): Wrapper
getComponent (selector: ComponentOptions$1): Wrapper
getComponent>(selector: FunctionalComponentOptions): Wrapper
getComponent (selector: RefSelector): Wrapper
getComponent (selector: NameSelector): Wrapper
find (selector: VueClass): Wrapper
find (selector: ComponentOptions$1): Wrapper
find>(selector: FunctionalComponentOptions): Wrapper
find(selector: string): Wrapper
find (selector: RefSelector): Wrapper
find (selector: NameSelector): Wrapper
findAll (selector: VueClass): WrapperArray
findAll (selector: ComponentOptions$1): WrapperArray
findAll>(selector: FunctionalComponentOptions): WrapperArray
findAll (selector: string): WrapperArray
findAll (selector: RefSelector): WrapperArray
findAll (selector: NameSelector): WrapperArray
findComponent (selector: VueClass): Wrapper
findComponent (selector: ComponentOptions$1): Wrapper
findComponent>(selector: FunctionalComponentOptions): Wrapper
findComponent (selector: RefSelector): Wrapper
findComponent (selector: NameSelector): Wrapper
findAllComponents (selector: VueClass): WrapperArray
findAllComponents (selector: ComponentOptions$1): WrapperArray
findAllComponents>(selector: FunctionalComponentOptions): WrapperArray
findAllComponents(selector: RefSelector): WrapperArray
findAllComponents(selector: NameSelector): WrapperArray
html (): string
text (): string
name (): string
emitted (): { [name: string]: Array>|undefined }
emitted (event: string): Array|undefined
emittedByOrder (): Array<{ name: string, args: Array }>
}
interface WrapperArray extends BaseWrapper {
readonly length: number;
readonly wrappers: Array>;
at(index: number): Wrapper;
filter(
predicate: (
value: Wrapper,
index: number,
array: Wrapper[]
) => any
): WrapperArray;
}
interface WrapperOptions {
attachedToDocument?: boolean
}
interface VueTestUtilsConfigOptions {
stubs: Record
mocks: Record
methods: Record
provide?: Record,
showDeprecationWarnings?: boolean
deprecationWarningHandler?: Function
}
/**
* Type for component passed to "mount"
*
* @interface VueComponent
* @example
* import Hello from './Hello.vue'
* ^^^^^ this type
* mount(Hello)
*/
declare type VueComponent = Vue.ComponentOptions | Vue.VueConstructor;
/**
* Options to pass to the component when creating it, like
* props.
*
* @interface ComponentOptions
*/
declare type ComponentOptions = Record;
declare type VueLocalComponents = Record;
declare type VueFilters = {
[key: string]: (value: string) => string;
};
declare type VueDirectives = {
[key: string]: Function | Object;
};
declare type VueMixin = unknown;
declare type VueMixins = VueMixin | VueMixin[];
declare type VuePluginOptions = unknown;
declare type VuePlugin = unknown | [unknown, VuePluginOptions];
/**
* A single Vue plugin or a list of plugins to register
*/
declare type VuePlugins = VuePlugin[];
/**
* Additional Vue services to register while mounting the component, like
* local components, plugins, etc.
*
* @interface MountOptionsExtensions
* @see https://github.com/cypress-io/cypress/tree/develop/npm/vue#examples
*/
interface MountOptionsExtensions {
/**
* Extra local components
*
* @memberof MountOptionsExtensions
* @see https://github.com/cypress-io/cypress/tree/develop/npm/vue#examples
* @example
* import Hello from './Hello.vue'
* // imagine Hello needs AppComponent
* // that it uses in its template like
* // during testing we can replace it with a mock component
* const appComponent = ...
* const components = {
* 'app-component': appComponent
* },
* mount(Hello, { extensions: { components }})
*/
components?: VueLocalComponents;
/**
* Optional Vue filters to install while mounting the component
*
* @memberof MountOptionsExtensions
* @see https://github.com/cypress-io/cypress/tree/develop/npm/vue#examples
* @example
* const filters = {
* reverse: (s) => s.split('').reverse().join(''),
* }
* mount(Hello, { extensions: { filters }})
*/
filters?: VueFilters;
/**
* Optional Vue mixin(s) to install when mounting the component
*
* @memberof MountOptionsExtensions
* @alias mixins
* @see https://github.com/cypress-io/cypress/tree/develop/npm/vue#examples
*/
mixin?: VueMixins;
/**
* Optional Vue mixin(s) to install when mounting the component
*
* @memberof MountOptionsExtensions
* @alias mixin
* @see https://github.com/cypress-io/cypress/tree/develop/npm/vue#examples
*/
mixins?: VueMixins;
/**
* A single plugin or multiple plugins.
*
* @see https://github.com/cypress-io/cypress/tree/develop/npm/vue#examples
* @alias plugins
* @memberof MountOptionsExtensions
*/
use?: VuePlugins;
/**
* A single plugin or multiple plugins.
*
* @see https://github.com/cypress-io/cypress/tree/develop/npm/vue#examples
* @alias use
* @memberof MountOptionsExtensions
*/
plugins?: VuePlugins;
/**
* Optional Vue directives to install while mounting the component
*
* @memberof MountOptionsExtensions
* @see https://github.com/cypress-io/cypress/tree/develop/npm/vue#examples
* @example
* const directives = {
* custom: {
* name: 'custom',
* bind (el, binding) {
* el.dataset['custom'] = binding.value
* },
* unbind (el) {
* el.removeAttribute('data-custom')
* },
* },
* }
* mount(Hello, { extensions: { directives }})
*/
directives?: VueDirectives;
}
/**
* Options controlling how the component is going to be mounted,
* including global Vue plugins and extensions.
*
* @interface MountOptions
*/
interface MountOptions {
/**
* Vue instance to use.
*
* @deprecated
* @memberof MountOptions
*/
vue: unknown;
/**
* Extra Vue plugins, mixins, local components to register while
* mounting this component
*
* @memberof MountOptions
* @see https://github.com/cypress-io/cypress/tree/develop/npm/vue#examples
*/
extensions: MountOptionsExtensions;
}
/**
* Utility type for union of options passed to "mount(..., options)"
*/
declare type MountOptionsArgument = Partial;
declare global {
namespace Cypress {
interface Cypress {
/**
* Mounted Vue instance is available under Cypress.vue
* @memberof Cypress
* @example
* mount(Greeting)
* .then(() => {
* Cypress.vue.message = 'Hello There'
* })
* // new message is displayed
* cy.contains('Hello There').should('be.visible')
*/
vue: Vue;
vueWrapper: Wrapper;
}
}
}
/**
* Mounts a Vue component inside Cypress browser.
* @param {VueComponent} component imported from Vue file
* @param {MountOptionsArgument} optionsOrProps used to pass options to component being mounted
* @returns {Cypress.Chainable<{wrapper: Wrapper, component: T}
* @example
* import { mount } from '@cypress/vue'
* import { Stepper } from './Stepper.vue'
*
* it('mounts', () => {
* cy.mount(Stepper)
* cy.get('[data-cy=increment]').click()
* cy.get('[data-cy=counter]').should('have.text', '1')
* })
* @see {@link https://on.cypress.io/mounting-vue} for more details.
*
*/
declare const mount: (component: VueComponent, optionsOrProps?: MountOptionsArgument) => Cypress.Chainable<{
wrapper: Wrapper;
component: Wrapper['vm'];
}>;
/**
* Helper function for mounting a component quickly in test hooks.
* @example
* import {mountCallback} from '@cypress/vue2'
* beforeEach(mountVue(component, options))
*
* Removed as of Cypress 11.0.0.
* @see https://on.cypress.io/migration-11-0-0-component-testing-updates
*/
declare const mountCallback: (component: VueComponent, options?: MountOptionsArgument) => () => void;
export { mount, mountCallback };