UNPKG

cypress

Version:

Cypress is a next generation front end testing tool built for the modern web

1,635 lines (1,605 loc) 315 kB
/** * @cypress/vue v0.0.0-development * (c) 2025 Cypress.io * Released under the MIT License */ import * as Vue from 'vue'; import { nextTick, defineComponent, computed, h, shallowReactive, reactive, ref, createApp, transformVNodeArgs, setDevtoolsHook, Transition, BaseTransition, TransitionGroup, isRef } from 'vue'; import { compile } from '@vue/compiler-dom'; import { renderToString as renderToString$1 } from '@vue/server-renderer'; /****************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { var e = new Error(message); return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; }; const ROOT_SELECTOR = '[data-cy-root]'; /** * Gets the root element used to mount the component. * @returns {HTMLElement} The root element * @throws {Error} If the root element is not found */ const getContainerEl = () => { const el = document.querySelector(ROOT_SELECTOR); if (el) { return el; } throw Error(`No element found that matches selector ${ROOT_SELECTOR}. Please add a root element with data-cy-root attribute to your "component-index.html" file so that Cypress can attach your component to the DOM.`); }; /** * Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook * @param optionalCallback Callback to be called before the next test runs */ function setupHooks(optionalCallback) { // We don't want CT side effects to run when e2e // testing so we early return. // System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts if (Cypress.testingType !== 'component') { return; } // When running component specs, we cannot allow "cy.visit" // because it will wipe out our preparation work, and does not make much sense // thus we overwrite "cy.visit" to throw an error Cypress.Commands.overwrite('visit', () => { throw new Error('cy.visit from a component spec is not allowed'); }); Cypress.Commands.overwrite('session', () => { throw new Error('cy.session from a component spec is not allowed'); }); Cypress.Commands.overwrite('origin', () => { throw new Error('cy.origin from a component spec is not allowed'); }); // @ts-ignore Cypress.on('test:before:after:run:async', () => { optionalCallback === null || optionalCallback === void 0 ? void 0 : optionalCallback(); }); } /****************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise, SuppressedError, Symbol */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (g && (g = 0, op[0] && (_ = 0)), _) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); } typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { var e = new Error(message); return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; }; var Pluggable = /** @class */ (function () { function Pluggable() { this.installedPlugins = []; } Pluggable.prototype.install = function (handler, options) { if (typeof handler !== 'function') { console.error('plugin.install must receive a function'); handler = function () { return ({}); }; } this.installedPlugins.push({ handler: handler, options: options }); }; Pluggable.prototype.extend = function (instance) { var invokeSetup = function (_a) { var handler = _a.handler, options = _a.options; return handler(instance, options); // invoke the setup method passed to install }; var bindProperty = function (_a) { var property = _a[0], value = _a[1]; instance[property] = typeof value === 'function' ? value.bind(instance) : value; }; var addAllPropertiesFromSetup = function (setupResult) { setupResult = typeof setupResult === 'object' ? setupResult : {}; Object.entries(setupResult).forEach(bindProperty); }; this.installedPlugins.map(invokeSetup).forEach(addAllPropertiesFromSetup); }; /** For testing */ Pluggable.prototype.reset = function () { this.installedPlugins = []; }; return Pluggable; }()); var config = { global: { stubs: { transition: true, 'transition-group': true }, provide: {}, components: {}, config: {}, directives: {}, mixins: [], mocks: {}, plugins: [], renderStubDefaultSlot: false }, plugins: { VueWrapper: new Pluggable(), DOMWrapper: new Pluggable() } }; function mergeStubs(target, source) { if (source.stubs) { if (Array.isArray(source.stubs)) { source.stubs.forEach(function (x) { return (target[x] = true); }); } else { for (var _i = 0, _a = Object.entries(source.stubs); _i < _a.length; _i++) { var _b = _a[_i], k = _b[0], v = _b[1]; target[k] = v; } } } } // perform 1-level-deep-pseudo-clone merge in order to prevent config leaks // example: vue-router overwrites globalProperties.$router function mergeAppConfig(configGlobalConfig, mountGlobalConfig) { return __assign(__assign(__assign({}, configGlobalConfig), mountGlobalConfig), { globalProperties: __assign(__assign({}, configGlobalConfig === null || configGlobalConfig === void 0 ? void 0 : configGlobalConfig.globalProperties), mountGlobalConfig === null || mountGlobalConfig === void 0 ? void 0 : mountGlobalConfig.globalProperties) }); } function mergeGlobalProperties(mountGlobal) { var _a, _b, _c; if (mountGlobal === void 0) { mountGlobal = {}; } var stubs = {}; var configGlobal = (_a = config === null || config === void 0 ? void 0 : config.global) !== null && _a !== void 0 ? _a : {}; mergeStubs(stubs, configGlobal); mergeStubs(stubs, mountGlobal); var renderStubDefaultSlot = (_c = (_b = mountGlobal.renderStubDefaultSlot) !== null && _b !== void 0 ? _b : (configGlobal.renderStubDefaultSlot || (config === null || config === void 0 ? void 0 : config.renderStubDefaultSlot))) !== null && _c !== void 0 ? _c : false; if (config.renderStubDefaultSlot === true) { console.warn('config.renderStubDefaultSlot is deprecated, use config.global.renderStubDefaultSlot instead'); } return { mixins: __spreadArray(__spreadArray([], (configGlobal.mixins || []), true), (mountGlobal.mixins || []), true), plugins: __spreadArray(__spreadArray([], (configGlobal.plugins || []), true), (mountGlobal.plugins || []), true), stubs: stubs, components: __assign(__assign({}, configGlobal.components), mountGlobal.components), provide: __assign(__assign({}, configGlobal.provide), mountGlobal.provide), mocks: __assign(__assign({}, configGlobal.mocks), mountGlobal.mocks), config: mergeAppConfig(configGlobal.config, mountGlobal.config), directives: __assign(__assign({}, configGlobal.directives), mountGlobal.directives), renderStubDefaultSlot: renderStubDefaultSlot }; } var isObject = function (obj) { return !!obj && typeof obj === 'object'; }; function isClass(obj) { if (!(obj instanceof Object)) return; var isCtorClass = obj.constructor && obj.constructor.toString().substring(0, 5) === 'class'; if (!('prototype' in obj)) { return isCtorClass; } var prototype = obj.prototype; var isPrototypeCtorClass = prototype.constructor && prototype.constructor.toString && prototype.constructor.toString().substring(0, 5) === 'class'; return isCtorClass || isPrototypeCtorClass; } // https://stackoverflow.com/a/48218209 var mergeDeep = function (target, source) { var _a; if (!isObject(target) || !isObject(source)) { return source; } Object.keys(source) .concat(isClass(source) ? Object.getOwnPropertyNames((_a = Object.getPrototypeOf(source)) !== null && _a !== void 0 ? _a : {}) : Object.getOwnPropertyNames(source)) .forEach(function (key) { var targetValue = target[key]; var sourceValue = source[key]; if (Array.isArray(targetValue) && Array.isArray(sourceValue)) { target[key] = sourceValue; } else if (sourceValue instanceof Date) { target[key] = sourceValue; } else if (isObject(targetValue) && isObject(sourceValue)) { target[key] = mergeDeep(Object.assign({}, targetValue), sourceValue); } else { target[key] = sourceValue; } }); return target; }; function isClassComponent(component) { return typeof component === 'function' && '__vccOpts' in component; } function isComponent(component) { return Boolean(component && (typeof component === 'object' || typeof component === 'function')); } function isFunctionalComponent(component) { return typeof component === 'function' && !isClassComponent(component); } function isObjectComponent(component) { return Boolean(component && typeof component === 'object'); } function textContent(element) { var _a, _b; // we check if the element is a comment first // to return an empty string in that case, instead of the comment content return element.nodeType !== Node.COMMENT_NODE ? (_b = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '' : ''; } function hasOwnProperty(obj, prop) { return obj.hasOwnProperty(prop); } function isNotNullOrUndefined(obj) { return Boolean(obj); } function isRefSelector(selector) { return typeof selector === 'object' && 'ref' in selector; } function convertStubsToRecord(stubs) { if (Array.isArray(stubs)) { // ['Foo', 'Bar'] => { Foo: true, Bar: true } return stubs.reduce(function (acc, current) { acc[current] = true; return acc; }, {}); } return stubs; } var isDirectiveKey = function (key) { return key.match(/^v[A-Z].*/); }; function getComponentsFromStubs(stubs) { var normalizedStubs = convertStubsToRecord(stubs); return Object.fromEntries(Object.entries(normalizedStubs).filter(function (_a) { var key = _a[0]; return !isDirectiveKey(key); })); } function getDirectivesFromStubs(stubs) { var normalizedStubs = convertStubsToRecord(stubs); return Object.fromEntries(Object.entries(normalizedStubs) .filter(function (_a) { var key = _a[0], value = _a[1]; return isDirectiveKey(key) && value !== false; }) .map(function (_a) { var key = _a[0], value = _a[1]; return [key.substring(1), value]; })); } function hasSetupState(vm) { return (vm && vm.$.devtoolsRawSetupState); } function isScriptSetup(vm) { return (vm && vm.$.setupState.__isScriptSetup); } var _globalThis; var getGlobalThis = function () { return (_globalThis || (_globalThis = typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {})); }; var ignorableKeyModifiers = [ 'stop', 'prevent', 'self', 'exact', 'prevent', 'capture' ]; var systemKeyModifiers = ['ctrl', 'shift', 'alt', 'meta']; var mouseKeyModifiers = ['left', 'middle', 'right']; var keyCodesByKeyName = { backspace: 8, tab: 9, enter: 13, esc: 27, space: 32, pageup: 33, pagedown: 34, end: 35, home: 36, left: 37, up: 38, right: 39, down: 40, insert: 45, delete: 46 }; var domEvents = { abort: { eventInterface: 'Event', bubbles: false, cancelable: false }, afterprint: { eventInterface: 'Event', bubbles: false, cancelable: false }, animationend: { eventInterface: 'AnimationEvent', bubbles: true, cancelable: false }, animationiteration: { eventInterface: 'AnimationEvent', bubbles: true, cancelable: false }, animationstart: { eventInterface: 'AnimationEvent', bubbles: true, cancelable: false }, appinstalled: { eventInterface: 'Event', bubbles: false, cancelable: false }, /** * @deprecated */ audioprocess: { eventInterface: 'AudioProcessingEvent', bubbles: false, cancelable: false }, audioend: { eventInterface: 'Event', bubbles: false, cancelable: false }, audiostart: { eventInterface: 'Event', bubbles: false, cancelable: false }, beforeprint: { eventInterface: 'Event', bubbles: false, cancelable: false }, beforeunload: { eventInterface: 'BeforeUnloadEvent', bubbles: false, cancelable: true }, beginEvent: { eventInterface: 'TimeEvent', bubbles: false, cancelable: false }, blur: { eventInterface: 'FocusEvent', bubbles: false, cancelable: false }, boundary: { eventInterface: 'SpeechSynthesisEvent', bubbles: false, cancelable: false }, cached: { eventInterface: 'Event', bubbles: false, cancelable: false }, canplay: { eventInterface: 'Event', bubbles: false, cancelable: false }, canplaythrough: { eventInterface: 'Event', bubbles: false, cancelable: false }, change: { eventInterface: 'Event', bubbles: true, cancelable: false }, chargingchange: { eventInterface: 'Event', bubbles: false, cancelable: false }, chargingtimechange: { eventInterface: 'Event', bubbles: false, cancelable: false }, checking: { eventInterface: 'Event', bubbles: false, cancelable: false }, click: { eventInterface: 'MouseEvent', bubbles: true, cancelable: true }, close: { eventInterface: 'Event', bubbles: false, cancelable: false }, complete: { eventInterface: 'OfflineAudioCompletionEvent', bubbles: false, cancelable: false }, compositionend: { eventInterface: 'CompositionEvent', bubbles: true, cancelable: true }, compositionstart: { eventInterface: 'CompositionEvent', bubbles: true, cancelable: true }, compositionupdate: { eventInterface: 'CompositionEvent', bubbles: true, cancelable: false }, contextmenu: { eventInterface: 'MouseEvent', bubbles: true, cancelable: true }, copy: { eventInterface: 'ClipboardEvent', bubbles: true, cancelable: true }, cut: { eventInterface: 'ClipboardEvent', bubbles: true, cancelable: true }, dblclick: { eventInterface: 'MouseEvent', bubbles: true, cancelable: true }, devicechange: { eventInterface: 'Event', bubbles: false, cancelable: false }, devicelight: { eventInterface: 'DeviceLightEvent', bubbles: false, cancelable: false }, devicemotion: { eventInterface: 'DeviceMotionEvent', bubbles: false, cancelable: false }, deviceorientation: { eventInterface: 'DeviceOrientationEvent', bubbles: false, cancelable: false }, deviceproximity: { eventInterface: 'DeviceProximityEvent', bubbles: false, cancelable: false }, dischargingtimechange: { eventInterface: 'Event', bubbles: false, cancelable: false }, DOMActivate: { eventInterface: 'UIEvent', bubbles: true, cancelable: true }, DOMAttributeNameChanged: { eventInterface: 'MutationNameEvent', bubbles: true, cancelable: true }, DOMAttrModified: { eventInterface: 'MutationEvent', bubbles: true, cancelable: true }, DOMCharacterDataModified: { eventInterface: 'MutationEvent', bubbles: true, cancelable: true }, DOMContentLoaded: { eventInterface: 'Event', bubbles: true, cancelable: true }, DOMElementNameChanged: { eventInterface: 'MutationNameEvent', bubbles: true, cancelable: true }, DOMFocusIn: { eventInterface: 'FocusEvent', bubbles: true, cancelable: true }, DOMFocusOut: { eventInterface: 'FocusEvent', bubbles: true, cancelable: true }, DOMNodeInserted: { eventInterface: 'MutationEvent', bubbles: true, cancelable: true }, DOMNodeInsertedIntoDocument: { eventInterface: 'MutationEvent', bubbles: true, cancelable: true }, DOMNodeRemoved: { eventInterface: 'MutationEvent', bubbles: true, cancelable: true }, DOMNodeRemovedFromDocument: { eventInterface: 'MutationEvent', bubbles: true, cancelable: true }, /** * @deprecated */ DOMSubtreeModified: { eventInterface: 'MutationEvent', bubbles: true, cancelable: false }, downloading: { eventInterface: 'Event', bubbles: false, cancelable: false }, drag: { eventInterface: 'DragEvent', bubbles: true, cancelable: true }, dragend: { eventInterface: 'DragEvent', bubbles: true, cancelable: false }, dragenter: { eventInterface: 'DragEvent', bubbles: true, cancelable: true }, dragleave: { eventInterface: 'DragEvent', bubbles: true, cancelable: false }, dragover: { eventInterface: 'DragEvent', bubbles: true, cancelable: true }, dragstart: { eventInterface: 'DragEvent', bubbles: true, cancelable: true }, drop: { eventInterface: 'DragEvent', bubbles: true, cancelable: true }, durationchange: { eventInterface: 'Event', bubbles: false, cancelable: false }, emptied: { eventInterface: 'Event', bubbles: false, cancelable: false }, end: { eventInterface: 'Event', bubbles: false, cancelable: false }, ended: { eventInterface: 'Event', bubbles: false, cancelable: false }, endEvent: { eventInterface: 'TimeEvent', bubbles: false, cancelable: false }, error: { eventInterface: 'Event', bubbles: false, cancelable: false }, focus: { eventInterface: 'FocusEvent', bubbles: false, cancelable: false }, focusin: { eventInterface: 'FocusEvent', bubbles: true, cancelable: false }, focusout: { eventInterface: 'FocusEvent', bubbles: true, cancelable: false }, fullscreenchange: { eventInterface: 'Event', bubbles: true, cancelable: false }, fullscreenerror: { eventInterface: 'Event', bubbles: true, cancelable: false }, gamepadconnected: { eventInterface: 'GamepadEvent', bubbles: false, cancelable: false }, gamepaddisconnected: { eventInterface: 'GamepadEvent', bubbles: false, cancelable: false }, gotpointercapture: { eventInterface: 'PointerEvent', bubbles: false, cancelable: false }, hashchange: { eventInterface: 'HashChangeEvent', bubbles: true, cancelable: false }, lostpointercapture: { eventInterface: 'PointerEvent', bubbles: false, cancelable: false }, input: { eventInterface: 'Event', bubbles: true, cancelable: false }, invalid: { eventInterface: 'Event', cancelable: true, bubbles: false }, keydown: { eventInterface: 'KeyboardEvent', bubbles: true, cancelable: true }, keypress: { eventInterface: 'KeyboardEvent', bubbles: true, cancelable: true }, keyup: { eventInterface: 'KeyboardEvent', bubbles: true, cancelable: true }, languagechange: { eventInterface: 'Event', bubbles: false, cancelable: false }, levelchange: { eventInterface: 'Event', bubbles: false, cancelable: false }, load: { eventInterface: 'UIEvent', bubbles: false, cancelable: false }, loadeddata: { eventInterface: 'Event', bubbles: false, cancelable: false }, loadedmetadata: { eventInterface: 'Event', bubbles: false, cancelable: false }, loadend: { eventInterface: 'ProgressEvent', bubbles: false, cancelable: false }, loadstart: { eventInterface: 'ProgressEvent', bubbles: false, cancelable: false }, mark: { eventInterface: 'SpeechSynthesisEvent', bubbles: false, cancelable: false }, message: { eventInterface: 'MessageEvent', bubbles: false, cancelable: false }, messageerror: { eventInterface: 'MessageEvent', bubbles: false, cancelable: false }, mousedown: { eventInterface: 'MouseEvent', bubbles: true, cancelable: true }, mouseenter: { eventInterface: 'MouseEvent', bubbles: false, cancelable: false }, mouseleave: { eventInterface: 'MouseEvent', bubbles: false, cancelable: false }, mousemove: { eventInterface: 'MouseEvent', bubbles: true, cancelable: true }, mouseout: { eventInterface: 'MouseEvent', bubbles: true, cancelable: true }, mouseover: { eventInterface: 'MouseEvent', bubbles: true, cancelable: true }, mouseup: { eventInterface: 'MouseEvent', bubbles: true, cancelable: true }, nomatch: { eventInterface: 'SpeechRecognitionEvent', bubbles: false, cancelable: false }, notificationclick: { eventInterface: 'NotificationEvent', bubbles: false, cancelable: false }, noupdate: { eventInterface: 'Event', bubbles: false, cancelable: false }, obsolete: { eventInterface: 'Event', bubbles: false, cancelable: false }, offline: { eventInterface: 'Event', bubbles: false, cancelable: false }, online: { eventInterface: 'Event', bubbles: false, cancelable: false }, open: { eventInterface: 'Event', bubbles: false, cancelable: false }, orientationchange: { eventInterface: 'Event', bubbles: false, cancelable: false }, pagehide: { eventInterface: 'PageTransitionEvent', bubbles: false, cancelable: false }, pageshow: { eventInterface: 'PageTransitionEvent', bubbles: false, cancelable: false }, paste: { eventInterface: 'ClipboardEvent', bubbles: true, cancelable: true }, pause: { eventInterface: 'SpeechSynthesisEvent', bubbles: false, cancelable: false }, pointercancel: { eventInterface: 'PointerEvent', bubbles: true, cancelable: false }, pointerdown: { eventInterface: 'PointerEvent', bubbles: true, cancelable: true }, pointerenter: { eventInterface: 'PointerEvent', bubbles: false, cancelable: false }, pointerleave: { eventInterface: 'PointerEvent', bubbles: false, cancelable: false }, pointerlockchange: { eventInterface: 'Event', bubbles: true, cancelable: false }, pointerlockerror: { eventInterface: 'Event', bubbles: true, cancelable: false }, pointermove: { eventInterface: 'PointerEvent', bubbles: true, cancelable: true }, pointerout: { eventInterface: 'PointerEvent', bubbles: true, cancelable: true }, pointerover: { eventInterface: 'PointerEvent', bubbles: true, cancelable: true }, pointerup: { eventInterface: 'PointerEvent', bubbles: true, cancelable: true }, play: { eventInterface: 'Event', bubbles: false, cancelable: false }, playing: { eventInterface: 'Event', bubbles: false, cancelable: false }, popstate: { eventInterface: 'PopStateEvent', bubbles: true, cancelable: false }, progress: { eventInterface: 'ProgressEvent', bubbles: false, cancelable: false }, push: { eventInterface: 'PushEvent', bubbles: false, cancelable: false }, pushsubscriptionchange: { eventInterface: 'PushEvent', bubbles: false, cancelable: false }, ratechange: { eventInterface: 'Event', bubbles: false, cancelable: false }, readystatechange: { eventInterface: 'Event', bubbles: false, cancelable: false }, repeatEvent: { eventInterface: 'TimeEvent', bubbles: false, cancelable: false }, reset: { eventInterface: 'Event', bubbles: true, cancelable: true }, resize: { eventInterface: 'UIEvent', bubbles: false, cancelable: false }, resourcetimingbufferfull: { eventInterface: 'Performance', bubbles: true, cancelable: true }, result: { eventInterface: 'SpeechRecognitionEvent', bubbles: false, cancelable: false }, resume: { eventInterface: 'SpeechSynthesisEvent', bubbles: false, cancelable: false }, scroll: { eventInterface: 'UIEvent', bubbles: false, cancelable: false }, seeked: { eventInterface: 'Event', bubbles: false, cancelable: false }, seeking: { eventInterface: 'Event', bubbles: false, cancelable: false }, select: { eventInterface: 'UIEvent', bubbles: true, cancelable: false }, selectstart: { eventInterface: 'Event', bubbles: true, cancelable: true }, selectionchange: { eventInterface: 'Event', bubbles: false, cancelable: false }, show: { eventInterface: 'MouseEvent', bubbles: false, cancelable: false }, slotchange: { eventInterface: 'Event', bubbles: true, cancelable: false }, soundend: { eventInterface: 'Event', bubbles: false, cancelable: false }, soundstart: { eventInterface: 'Event', bubbles: false, cancelable: false }, speechend: { eventInterface: 'Event', bubbles: false, cancelable: false }, speechstart: { eventInterface: 'Event', bubbles: false, cancelable: false }, stalled: { eventInterface: 'Event', bubbles: false, cancelable: false }, start: { eventInterface: 'SpeechSynthesisEvent', bubbles: false, cancelable: false }, storage: { eventInterface: 'StorageEvent', bubbles: false, cancelable: false }, submit: { eventInterface: 'Event', bubbles: true, cancelable: true }, success: { eventInterface: 'Event', bubbles: false, cancelable: false }, suspend: { eventInterface: 'Event', bubbles: false, cancelable: false }, SVGAbort: { eventInterface: 'SVGEvent', bubbles: true, cancelable: false }, SVGError: { eventInterface: 'SVGEvent', bubbles: true, cancelable: false }, SVGLoad: { eventInterface: 'SVGEvent', bubbles: false, cancelable: false }, SVGResize: { eventInterface: 'SVGEvent', bubbles: true, cancelable: false }, SVGScroll: { eventInterface: 'SVGEvent', bubbles: true, cancelable: false }, SVGUnload: { eventInterface: 'SVGEvent', bubbles: false, cancelable: false }, SVGZoom: { eventInterface: 'SVGZoomEvent', bubbles: true, cancelable: false }, timeout: { eventInterface: 'ProgressEvent', bubbles: false, cancelable: false }, timeupdate: { eventInterface: 'Event', bubbles: false, cancelable: false }, touchcancel: { eventInterface: 'TouchEvent', bubbles: true, cancelable: false }, touchend: { eventInterface: 'TouchEvent', bubbles: true, cancelable: true }, touchmove: { eventInterface: 'TouchEvent', bubbles: true, cancelable: true }, touchstart: { eventInterface: 'TouchEvent', bubbles: true, cancelable: true }, transitionend: { eventInterface: 'TransitionEvent', bubbles: true, cancelable: true }, unload: { eventInterface: 'UIEvent', bubbles: false, cancelable: false }, updateready: { eventInterface: 'Event', bubbles: false, cancelable: false }, userproximity: { eventInterface: 'UserProximityEvent', bubbles: false, cancelable: false }, voiceschanged: { eventInterface: 'Event', bubbles: false, cancelable: false }, visibilitychange: { eventInterface: 'Event', bubbles: true, cancelable: false }, volumechange: { eventInterface: 'Event', bubbles: false, cancelable: false }, waiting: { eventInterface: 'Event', bubbles: false, cancelable: false }, wheel: { eventInterface: 'WheelEvent', bubbles: true, cancelable: true } }; /** * Groups modifiers into lists */ function generateModifiers(modifiers, isOnClick) { var keyModifiers = []; var systemModifiers = []; for (var i = 0; i < modifiers.length; i++) { var modifier = modifiers[i]; // addEventListener() options, e.g. .passive & .capture, that we dont need to handle if (ignorableKeyModifiers.includes(modifier)) { continue; } // modifiers that require special conversion // if passed a left/right key modifier with onClick, add it here as well. if (systemKeyModifiers.includes(modifier) || (mouseKeyModifiers.includes(modifier) && isOnClick)) { systemModifiers.push(modifier); } else { keyModifiers.push(modifier); } } return { keyModifiers: keyModifiers, systemModifiers: systemModifiers }; } function getEventProperties(eventParams) { var modifiers = eventParams.modifiers, _a = eventParams.options, options = _a === void 0 ? {} : _a, eventType = eventParams.eventType; var isOnClick = eventType === 'click'; var _b = generateModifiers(modifiers, isOnClick), keyModifiers = _b.keyModifiers, systemModifiers = _b.systemModifiers; if (isOnClick) { // if it's a right click, it should fire a `contextmenu` event if (systemModifiers.includes('right')) { eventType = 'contextmenu'; options.button = 2; // if its a middle click, fire a `mouseup` event } else if (systemModifiers.includes('middle')) { eventType = 'mouseup'; options.button = 1; } } var meta = domEvents[eventType] || { eventInterface: 'Event', cancelable: true, bubbles: true }; // convert `shift, ctrl` to `shiftKey, ctrlKey` // allows trigger('keydown.shift.ctrl.n') directly var systemModifiersMeta = systemModifiers.reduce(function (all, key) { all["".concat(key, "Key")] = true; return all; }, {}); // get the keyCode for backwards compat var keyCode = keyCodesByKeyName[keyModifiers[0]] || (options && (options.keyCode || options.code)); var eventProperties = __assign(__assign(__assign(__assign({}, systemModifiersMeta), options), { bubbles: meta.bubbles, cancelable: meta.cancelable, // Any derived options should go here keyCode: keyCode, code: keyCode }), (keyModifiers[0] ? { key: keyModifiers[0] } : {})); return { eventProperties: eventProperties, meta: meta, eventType: eventType }; } function createEvent(eventParams) { var _a = getEventProperties(eventParams), eventProperties = _a.eventProperties, meta = _a.meta, eventType = _a.eventType; // user defined eventInterface var eventInterface = meta.eventInterface; var metaEventInterface = window[eventInterface]; var SupportedEventInterface = typeof metaEventInterface === 'function' ? metaEventInterface : window.Event; return new SupportedEventInterface(eventType, // event properties can only be added when the event is instantiated // custom properties must be added after the event has been instantiated eventProperties); } function createDOMEvent(eventString, options) { // split eventString like `keydown.ctrl.shift` into `keydown` and array of modifiers var _a = eventString.split('.'), eventType = _a[0], modifiers = _a.slice(1); var eventParams = { eventType: eventType, modifiers: modifiers, options: options }; var event = createEvent(eventParams); var eventPrototype = Object.getPrototypeOf(event); // attach custom options to the event, like `relatedTarget` and so on. options && Object.keys(options).forEach(function (key) { var propertyDescriptor = Object.getOwnPropertyDescriptor(eventPrototype, key); var canSetProperty = !(propertyDescriptor && propertyDescriptor.set === undefined); if (canSetProperty) { event[key] = options[key]; } }); return event; } // Stubbing occurs when in vnode transformer we're swapping // component vnode type due to stubbing either component // or directive on component // In order to be able to find components we need to track pairs // stub --> original component // Having this as global might feel unsafe at first point // One can assume that sharing stub map across mounts might // lead to false matches, however our vnode mappers always // produce new nodeTypes for each mount even if you're reusing // same stub, so we're safe and do not need to pass these stubs // for each mount operation var stubs = new WeakMap(); function registerStub(_a) { var source = _a.source, stub = _a.stub; stubs.set(stub, source); } function getOriginalComponentFromStub(stub) { return stubs.get(stub); } var cacheStringFunction = function (fn) { var cache = Object.create(null); return (function (str) { var hit = cache[str]; return hit || (cache[str] = fn(str)); }); }; var camelizeRE = /-(\w)/g; var camelize = cacheStringFunction(function (str) { return str.replace(camelizeRE, function (_, c) { return (c ? c.toUpperCase() : ''); }); }); var capitalize = cacheStringFunction(function (str) { return str.charAt(0).toUpperCase() + str.slice(1); }); var hyphenateRE = /\B([A-Z])/g; var hyphenate = cacheStringFunction(function (str) { return str.replace(hyphenateRE, '-$1').toLowerCase(); }); function matchName(target, sourceName) { var camelized = camelize(target); var capitalized = capitalize(camelized); return (!!sourceName && (sourceName === target || sourceName === camelized || sourceName === capitalized || capitalize(camelize(sourceName)) === capitalized)); } function isCompatEnabled(key) { var _a, _b; return (_b = (_a = Vue.compatUtils) === null || _a === void 0 ? void 0 : _a.isCompatEnabled(key)) !== null && _b !== void 0 ? _b : false; } function isLegacyExtendedComponent(component) { if (!isCompatEnabled('GLOBAL_EXTEND') || typeof component !== 'function') { return false; } return (hasOwnProperty(component, 'super') && component.super.extend({}).super === component.super); } function unwrapLegacyVueExtendComponent(selector) { return isLegacyExtendedComponent(selector) ? selector.options : selector; } function isLegacyFunctionalComponent(component) { return Boolean(component && typeof component === 'object' && hasOwnProperty(component, 'functional') && component.functional); } var getComponentNameInSetup = function (instance, type) { return Object.keys((instance === null || instance === void 0 ? void 0 : instance.setupState) || {}).find(function (key) { var _a; return ((_a = Object.getOwnPropertyDescriptor(instance.setupState, key)) === null || _a === void 0 ? void 0 : _a.value) === type; }); }; var getComponentRegisteredName = function (instance, type) { if (!instance || !instance.parent) return null; // try to infer the name based on local resolution var registry = instance.type.components; for (var key in registry) { if (registry[key] === type) { return key; } } // try to retrieve name imported in script setup return getComponentNameInSetup(instance.parent, type) || null; }; var getComponentName = function (instance, type) { if (isObjectComponent(type)) { return ( // If the component we stub is a script setup component and is automatically // imported by unplugin-vue-components we can only get its name through // the `__name` property. getComponentNameInSetup(instance, type) || type.name || type.__name || ''); } if (isLegacyExtendedComponent(type)) { return unwrapLegacyVueExtendComponent(type).name || ''; } if (isFunctionalComponent(type)) { return type.displayName || type.name; } return ''; }; /** * Detect whether a selector matches a VNode * @param node * @param selector * @return {boolean | ((value: any) => boolean)} */ function matches(node, rawSelector) { var _a, _b, _c; var selector = unwrapLegacyVueExtendComponent(rawSelector); // do not return none Vue components if (!node.component) return false; var nodeType = node.type; if (!isComponent(nodeType)) return false; if (typeof selector === 'string') { return (_b = (_a = node.el) === null || _a === void 0 ? void 0 : _a.matches) === null || _b === void 0 ? void 0 : _b.call(_a, selector); } // When we're using stubs we want user to be able to // find stubbed components both by original component // or stub definition. That's why we are trying to // extract original component and also stub, which was // used to create specialized stub for render var nodeTypeCandidates = [ nodeType, getOriginalComponentFromStub(nodeType) ].filter(Boolean); // our selector might be a stub itself var target = (_c = getOriginalComponentFromStub(selector)) !== null && _c !== void 0 ? _c : selector; if (nodeTypeCandidates.includes(target)) { return true; } var componentName; componentName = getComponentName(node.component, nodeType); var selectorName = selector.name; // the component and selector both have a name if (componentName && selectorName) { return matchName(selectorName, componentName); } componentName = getComponentRegisteredName(node.component, nodeType) || undefined; // if a name is missing, then check the locally registered components in the parent if (node.component.parent) { var registry = node.component.parent.type.components; for (var key in registry) { // is it the selector if (!selectorName && registry[key] === selector) { selectorName = key; } // is it the component if (!componentName && registry[key] === nodeType) { componentName = key; } } } if (selectorName && componentName) { return matchName(selectorName, componentName); } return false; } /** * Filters out the null, undefined and primitive values, * to only keep VNode and VNodeArrayChildren values * @param value */ function nodesAsObject(value) { return !!value && typeof value === 'object'; } /** * Collect all children * @param nodes * @param children */ function aggregateChildren(nodes, children) { if (children && Array.isArray(children)) { var reversedNodes = __spreadArray([], children, true).reverse().filter(nodesAsObject); reversedNodes.forEach(function (node) { if (Array.isArray(node)) { aggregateChildren(nodes, node); } else { nodes.unshift(node); } }); } } function findAllVNodes(vnode, selector) { var matchingNodes = []; var nodes = [vnode]; while (nodes.length) { var node = nodes.shift(); aggregateChildren(nodes, node.children); if (node.component) { aggregateChildren(nodes, [node.component.subTree]); } if (node.suspense) { // match children if component is Suspense var activeBranch = node.suspense.activeBranch; aggregateChildren(nodes, [activeBranch]); } if (matches(node, selector) && !matchingNodes.includes(node)) { matchingNodes.push(node); } } return matchingNodes; } function find(root, selector) { var matchingVNodes = findAllVNodes(root, selector); if (typeof selector === 'string') { // When searching by CSS selector we want only one (topmost) vnode for each el` matchingVNodes = matchingVNodes.filter(function (vnode) { var _a; return ((_a = vnode.component.parent) === null || _a === void 0 ? void 0 : _a.vnode.el) !== vnode.el; }); } return matchingVNodes.map(function (vnode) { return vnode.component; }); } function createWrapperError(wrapperType) { return new Proxy(Object.create(null), { get: function (obj, prop) { switch (prop) { case 'then': // allows for better errors when wrapping `find` in `await` // https://github.com/vuejs/test-utils/issues/638 return; case 'exists': return function () { return false; }; default: throw new Error("Cannot call ".concat(String(prop), " on an empty ").concat(wrapperType, ".")); } } }); } /*! * isElementVisib