@vue/test-utils
Advanced tools
Comparing version 2.3.2 to 2.4.0-alpha.0
@@ -5,5 +5,4 @@ import { DefineComponent } from 'vue'; | ||
app: import("vue").App<Element>; | ||
el: HTMLDivElement; | ||
props: Record<string, unknown>; | ||
componentRef: import("vue").Ref<null>; | ||
}; |
@@ -1,35 +0,23 @@ | ||
import { FunctionalComponent, ComponentPublicInstance, ComponentOptionsWithObjectProps, ComponentOptionsWithArrayProps, ComponentOptionsWithoutProps, ExtractPropTypes, VNodeProps, ComponentOptionsMixin, DefineComponent, MethodOptions, AllowedComponentProps, ComponentCustomProps, ExtractDefaultPropTypes, EmitsOptions, ComputedOptions, ComponentPropsOptions, Prop } from 'vue'; | ||
import { DefineComponent, VNode } from 'vue'; | ||
import type { ComponentExposed, ComponentProps, ComponentSlots } from 'vue-component-type-helpers'; | ||
import { MountingOptions } from './types'; | ||
import { VueWrapper } from './vueWrapper'; | ||
type PublicProps = VNodeProps & AllowedComponentProps & ComponentCustomProps; | ||
export type ComponentMountingOptions<T> = T extends DefineComponent<infer PropsOrPropOptions, any, infer D, any, any> ? MountingOptions<Partial<ExtractDefaultPropTypes<PropsOrPropOptions>> & Omit<Readonly<ExtractPropTypes<PropsOrPropOptions>> & PublicProps, keyof ExtractDefaultPropTypes<PropsOrPropOptions>>, D> & Record<string, any> : MountingOptions<any>; | ||
export declare function mount<V extends {}>(originalComponent: { | ||
new (...args: any[]): V; | ||
__vccOpts: any; | ||
}, options?: MountingOptions<any> & Record<string, any>): VueWrapper<ComponentPublicInstance<V>>; | ||
export declare function mount<V extends {}, P>(originalComponent: { | ||
new (...args: any[]): V; | ||
__vccOpts: any; | ||
defaultProps?: Record<string, Prop<any>> | string[]; | ||
}, options?: MountingOptions<P & PublicProps> & Record<string, any>): VueWrapper<ComponentPublicInstance<V>>; | ||
export declare function mount<V extends {}>(originalComponent: { | ||
new (...args: any[]): V; | ||
registerHooks(keys: string[]): void; | ||
}, options?: MountingOptions<any> & Record<string, any>): VueWrapper<ComponentPublicInstance<V>>; | ||
export declare function mount<V extends {}, P>(originalComponent: { | ||
new (...args: any[]): V; | ||
props(Props: P): any; | ||
registerHooks(keys: string[]): void; | ||
}, options?: MountingOptions<P & PublicProps> & Record<string, any>): VueWrapper<ComponentPublicInstance<V>>; | ||
export declare function mount<Props extends {}, E extends EmitsOptions = {}>(originalComponent: FunctionalComponent<Props, E>, options?: MountingOptions<Props & PublicProps> & Record<string, any>): VueWrapper<ComponentPublicInstance<Props>>; | ||
export declare function mount<PropsOrPropOptions = {}, RawBindings = {}, D = {}, C extends ComputedOptions = ComputedOptions, M extends MethodOptions = MethodOptions, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = Record<string, any>, EE extends string = string, PP = PublicProps, Props = Readonly<ExtractPropTypes<PropsOrPropOptions>>, Defaults extends {} = ExtractDefaultPropTypes<PropsOrPropOptions>>(component: DefineComponent<PropsOrPropOptions, RawBindings, D, C, M, Mixin, Extends, E, EE, PP, Props, Defaults>, options?: MountingOptions<Partial<Defaults> & Omit<Props & PublicProps, keyof Defaults>, D> & Record<string, any>): VueWrapper<InstanceType<DefineComponent<PropsOrPropOptions, RawBindings, D, C, M, Mixin, Extends, EmitsOptions, EE, PP, Props, Defaults>>>; | ||
export declare function mount<T extends DefineComponent<any, any, any, any, any>>(component: T, options?: ComponentMountingOptions<T>): VueWrapper<InstanceType<T>>; | ||
export declare function mount<Props = {}, RawBindings = {}, D extends {} = {}, C extends ComputedOptions = {}, M extends Record<string, Function> = {}, E extends EmitsOptions = Record<string, any>, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, EE extends string = string>(componentOptions: ComponentOptionsWithoutProps<Props, RawBindings, D, C, M, E, Mixin, Extends, EE>, options?: MountingOptions<Props & PublicProps, D>): VueWrapper<ComponentPublicInstance<Props, RawBindings, D, C, M, E, VNodeProps & Props>> & Record<string, any>; | ||
export declare function mount<PropNames extends string, RawBindings, D extends {}, C extends ComputedOptions = {}, M extends Record<string, Function> = {}, E extends EmitsOptions = Record<string, any>, 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<PropNames, RawBindings, D, C, M, E, Mixin, Extends, EE, Props>, options?: MountingOptions<Props & PublicProps, D>): VueWrapper<ComponentPublicInstance<Props, RawBindings, D, C, M, E>>; | ||
export declare function mount<PropsOptions extends Readonly<ComponentPropsOptions>, RawBindings, D extends {}, C extends ComputedOptions = {}, M extends Record<string, Function> = {}, E extends EmitsOptions = Record<string, any>, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, EE extends string = string>(componentOptions: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M, E, Mixin, Extends, EE>, options?: MountingOptions<ExtractPropTypes<PropsOptions> & PublicProps, D>): VueWrapper<ComponentPublicInstance<ExtractPropTypes<PropsOptions>, RawBindings, D, C, M, E, VNodeProps & ExtractPropTypes<PropsOptions>>>; | ||
type ShimSlotReturnType<T> = T extends (...args: infer P) => any ? (...args: P) => any : never; | ||
type WithArray<T> = T | T[]; | ||
type ComponentData<T> = T extends { | ||
data?(...args: any): infer D; | ||
} ? D : {}; | ||
export type ComponentMountingOptions<T> = Omit<MountingOptions<ComponentProps<T>, ComponentData<T>>, 'slots'> & { | ||
slots?: { | ||
[K in keyof ComponentSlots<T>]: WithArray<ShimSlotReturnType<ComponentSlots<T>[K]> | string | VNode | (new () => any) | { | ||
template: string; | ||
}>; | ||
}; | ||
} & Record<string, unknown>; | ||
export declare function mount<T, C = T extends ((...args: any) => any) | (new (...args: any) => any) ? T : T extends { | ||
props?: infer Props; | ||
} ? DefineComponent<Props extends Readonly<(infer PropNames)[]> | (infer PropNames)[] ? { | ||
[key in PropNames extends string ? PropNames : string]?: any; | ||
} : Props> : DefineComponent>(originalComponent: T, options?: ComponentMountingOptions<C>): VueWrapper<ComponentExposed<C> & ComponentProps<C> & ComponentData<C>>; | ||
export declare const shallowMount: typeof mount; | ||
export {}; |
@@ -1,33 +0,8 @@ | ||
import { FunctionalComponent, ComponentOptionsWithObjectProps, ComponentOptionsWithArrayProps, ComponentOptionsWithoutProps, ExtractPropTypes, VNodeProps, ComponentOptionsMixin, DefineComponent, MethodOptions, AllowedComponentProps, ComponentCustomProps, ExtractDefaultPropTypes, EmitsOptions, ComputedOptions, ComponentPropsOptions, Prop } from 'vue'; | ||
import { MountingOptions } from './types'; | ||
type PublicProps = VNodeProps & AllowedComponentProps & ComponentCustomProps; | ||
type ComponentMountingOptions<T> = T extends DefineComponent<infer PropsOrPropOptions, any, infer D, any, any> ? MountingOptions<Partial<ExtractDefaultPropTypes<PropsOrPropOptions>> & Omit<Readonly<ExtractPropTypes<PropsOrPropOptions>> & PublicProps, keyof ExtractDefaultPropTypes<PropsOrPropOptions>>, D> & Record<string, any> : MountingOptions<any>; | ||
export declare function renderToString<V extends {}>(originalComponent: { | ||
new (...args: any[]): V; | ||
__vccOpts: any; | ||
}, options?: MountingOptions<any> & Record<string, any>): Promise<string>; | ||
export declare function renderToString<V extends {}, P>(originalComponent: { | ||
new (...args: any[]): V; | ||
__vccOpts: any; | ||
defaultProps?: Record<string, Prop<any>> | string[]; | ||
}, options?: MountingOptions<P & PublicProps> & Record<string, any>): Promise<string>; | ||
export declare function renderToString<V extends {}>(originalComponent: { | ||
new (...args: any[]): V; | ||
registerHooks(keys: string[]): void; | ||
}, options?: MountingOptions<any> & Record<string, any>): Promise<string>; | ||
export declare function renderToString<V extends {}, P>(originalComponent: { | ||
new (...args: any[]): V; | ||
props(Props: P): any; | ||
registerHooks(keys: string[]): void; | ||
}, options?: MountingOptions<P & PublicProps> & Record<string, any>): Promise<string>; | ||
export declare function renderToString<Props extends {}, E extends EmitsOptions = {}>(originalComponent: FunctionalComponent<Props, E>, options?: MountingOptions<Props & PublicProps> & Record<string, any>): Promise<string>; | ||
export declare function renderToString<PropsOrPropOptions = {}, RawBindings = {}, D = {}, C extends ComputedOptions = ComputedOptions, M extends MethodOptions = MethodOptions, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = Record<string, any>, EE extends string = string, PP = PublicProps, Props = Readonly<ExtractPropTypes<PropsOrPropOptions>>, Defaults extends {} = ExtractDefaultPropTypes<PropsOrPropOptions>>(component: DefineComponent<PropsOrPropOptions, RawBindings, D, C, M, Mixin, Extends, E, EE, PP, Props, Defaults>, options?: MountingOptions<Partial<Defaults> & Omit<Props & PublicProps, keyof Defaults>, D> & Record<string, any>): Promise<string>; | ||
export declare function renderToString<T extends DefineComponent<any, any, any, any, any>>(component: T, options?: ComponentMountingOptions<T>): Promise<string>; | ||
export declare function renderToString<Props = {}, RawBindings = {}, D extends {} = {}, C extends ComputedOptions = {}, M extends Record<string, Function> = {}, E extends EmitsOptions = Record<string, any>, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, EE extends string = string>(componentOptions: ComponentOptionsWithoutProps<Props, RawBindings, D, C, M, E, Mixin, Extends, EE>, options?: MountingOptions<Props & PublicProps, D>): Promise<string>; | ||
export declare function renderToString<PropNames extends string, RawBindings, D extends {}, C extends ComputedOptions = {}, M extends Record<string, Function> = {}, E extends EmitsOptions = Record<string, any>, 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<PropNames, RawBindings, D, C, M, E, Mixin, Extends, EE, Props>, options?: MountingOptions<Props & PublicProps, D>): Promise<string>; | ||
export declare function renderToString<PropsOptions extends Readonly<ComponentPropsOptions>, RawBindings, D extends {}, C extends ComputedOptions = {}, M extends Record<string, Function> = {}, E extends EmitsOptions = Record<string, any>, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, EE extends string = string>(componentOptions: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M, E, Mixin, Extends, EE>, options?: MountingOptions<ExtractPropTypes<PropsOptions> & PublicProps, D>): Promise<string>; | ||
export {}; | ||
import { DefineComponent } from 'vue'; | ||
import { ComponentMountingOptions } from './mount'; | ||
import { RenderMountingOptions } from './types'; | ||
export declare function renderToString<T, C = T extends ((...args: any) => any) | (new (...args: any) => any) ? T : T extends { | ||
props?: infer Props; | ||
} ? DefineComponent<Props extends Readonly<(infer PropNames)[]> | (infer PropNames)[] ? { | ||
[key in PropNames extends string ? PropNames : string]?: any; | ||
} : Props> : DefineComponent>(originalComponent: T, options?: ComponentMountingOptions<C> & Pick<RenderMountingOptions<any>, 'attachTo'>): Promise<string>; |
@@ -21,3 +21,3 @@ import { Component, ComponentOptions, Directive, Plugin, AppConfig, VNode, VNodeProps, FunctionalComponent, ComponentInternalInstance } from 'vue'; | ||
} & Record<string, any>; | ||
export interface MountingOptions<Props, Data = {}> { | ||
interface BaseMountingOptions<Props, Data = {}> { | ||
/** | ||
@@ -54,2 +54,13 @@ * Overrides component's default data. Must be a function. | ||
/** | ||
* Automatically stub out all the child components. | ||
* @default false | ||
* @see https://test-utils.vuejs.org/api/#slots | ||
*/ | ||
shallow?: boolean; | ||
} | ||
/** | ||
* Mounting options for `mount` and `shallowMount` | ||
*/ | ||
export interface MountingOptions<Props, Data = {}> extends BaseMountingOptions<Props, Data> { | ||
/** | ||
* Specify where to mount the component. | ||
@@ -60,8 +71,11 @@ * Can be a valid CSS selector, or an Element connected to the document. | ||
attachTo?: HTMLElement | string; | ||
} | ||
/** | ||
* Mounting options for `renderToString` | ||
*/ | ||
export interface RenderMountingOptions<Props, Data = {}> extends BaseMountingOptions<Props, Data> { | ||
/** | ||
* Automatically stub out all the child components. | ||
* @default false | ||
* @see https://test-utils.vuejs.org/api/#slots | ||
* Attach to is not available in SSR mode | ||
*/ | ||
shallow?: boolean; | ||
attachTo?: never; | ||
} | ||
@@ -68,0 +82,0 @@ export type Stub = boolean | Component | Directive; |
@@ -1,8 +0,6 @@ | ||
import { App, ComponentCustomProperties, ComponentPublicInstance } from 'vue'; | ||
import { App, ComponentPublicInstance } from 'vue'; | ||
import { VueNode } from './types'; | ||
import BaseWrapper from './baseWrapper'; | ||
import type { DOMWrapper } from './domWrapper'; | ||
export declare class VueWrapper<T extends Omit<ComponentPublicInstance, '$emit' | keyof ComponentCustomProperties> & { | ||
$emit: (event: any, ...args: any[]) => void; | ||
} & ComponentCustomProperties = ComponentPublicInstance> extends BaseWrapper<Node> { | ||
export declare class VueWrapper<VM = unknown, T extends ComponentPublicInstance = VM & ComponentPublicInstance> extends BaseWrapper<Node> { | ||
private readonly componentVM; | ||
@@ -9,0 +7,0 @@ private readonly rootVM; |
{ | ||
"name": "@vue/test-utils", | ||
"version": "2.3.2", | ||
"version": "2.4.0-alpha.0", | ||
"license": "MIT", | ||
@@ -28,14 +28,14 @@ "main": "dist/vue-test-utils.cjs.js", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "24.0.1", | ||
"@rollup/plugin-commonjs": "24.1.0", | ||
"@rollup/plugin-json": "6.0.0", | ||
"@rollup/plugin-node-resolve": "15.0.1", | ||
"@rollup/plugin-node-resolve": "15.0.2", | ||
"@rollup/plugin-replace": "5.0.2", | ||
"@rollup/plugin-typescript": "11.0.0", | ||
"@rollup/plugin-typescript": "11.1.0", | ||
"@types/js-beautify": "1.13.3", | ||
"@types/node": "18.15.3", | ||
"@typescript-eslint/eslint-plugin": "5.55.0", | ||
"@typescript-eslint/parser": "5.55.0", | ||
"@vitejs/plugin-vue": "4.0.0", | ||
"@vitejs/plugin-vue-jsx": "3.0.0", | ||
"@vitest/coverage-c8": "0.29.3", | ||
"@types/node": "18.15.11", | ||
"@typescript-eslint/eslint-plugin": "5.58.0", | ||
"@typescript-eslint/parser": "5.58.0", | ||
"@vitejs/plugin-vue": "4.1.0", | ||
"@vitejs/plugin-vue-jsx": "3.0.1", | ||
"@vitest/coverage-c8": "0.30.1", | ||
"@vue/compat": "3.2.47", | ||
@@ -46,4 +46,4 @@ "@vue/compiler-dom": "3.2.47", | ||
"c8": "7.13.0", | ||
"eslint": "8.36.0", | ||
"eslint-config-prettier": "8.7.0", | ||
"eslint": "8.38.0", | ||
"eslint-config-prettier": "8.8.0", | ||
"eslint-plugin-prettier": "4.2.1", | ||
@@ -53,16 +53,17 @@ "husky": "8.0.3", | ||
"jsdom-global": "3.0.2", | ||
"lint-staged": "13.2.0", | ||
"prettier": "2.8.4", | ||
"lint-staged": "13.2.1", | ||
"prettier": "2.8.7", | ||
"reflect-metadata": "0.1.13", | ||
"rollup": "3.19.1", | ||
"rollup": "3.20.2", | ||
"tslib": "2.5.0", | ||
"typescript": "4.9.5", | ||
"unplugin-vue-components": "0.24.1", | ||
"vite": "4.1.4", | ||
"vite": "4.2.1", | ||
"vitepress": "0.22.4", | ||
"vitest": "0.29.3", | ||
"vitest": "0.30.1", | ||
"vue": "3.2.47", | ||
"vue-class-component": "8.0.0-rc.1", | ||
"vue-component-type-helpers": "1.3.14-patch.2", | ||
"vue-router": "4.1.6", | ||
"vue-tsc": "1.2.0", | ||
"vue-tsc": "1.3.14", | ||
"vuex": "4.1.0" | ||
@@ -69,0 +70,0 @@ }, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1537342
39
37192
1