cypress 10.5.0 → 10.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/angular/CHANGELOG.md +43 -0
- package/angular/README.md +43 -112
- package/angular/dist/index.js +8 -6
- package/angular/dist/mount.d.ts +1 -0
- package/angular/package.json +6 -8
- package/lib/tasks/download.js +4 -3
- package/mount-utils/CHANGELOG.md +7 -0
- package/mount-utils/package.json +5 -1
- package/package.json +11 -5
- package/react/CHANGELOG.md +14 -0
- package/react/dist/createMount.d.ts +5 -2
- package/react/dist/cypress-react.cjs.js +80 -115
- package/react/dist/cypress-react.esm-bundler.js +66 -101
- package/react/dist/mount.d.ts +1 -0
- package/react/dist/mountHook.d.ts +1 -0
- package/react/dist/types.d.ts +1 -0
- package/react/package.json +3 -7
- package/react18/CHANGELOG.md +14 -0
- package/react18/dist/cypress-react.cjs.js +63 -89
- package/react18/dist/cypress-react.esm-bundler.js +49 -75
- package/react18/dist/index.d.ts +1 -0
- package/react18/package.json +2 -2
- package/svelte/CHANGELOG.md +6 -0
- package/svelte/README.md +83 -0
- package/svelte/dist/cypress-svelte.cjs.js +213 -0
- package/svelte/dist/cypress-svelte.esm-bundler.js +209 -0
- package/svelte/dist/index.d.ts +1 -0
- package/svelte/dist/mount.d.ts +30 -0
- package/svelte/package.json +43 -0
- package/types/cypress-type-helpers.d.ts +3 -1
- package/types/cypress.d.ts +61 -12
- package/vue/CHANGELOG.md +7 -0
- package/vue/dist/cypress-vue.cjs.js +30 -38
- package/vue/dist/cypress-vue.esm-bundler.js +30 -38
- package/vue/dist/index.d.ts +1 -0
- package/vue/package.json +3 -8
- package/vue2/CHANGELOG.md +7 -0
- package/vue2/dist/cypress-vue2.cjs.js +53 -84
- package/vue2/dist/cypress-vue2.esm-bundler.js +53 -84
- package/vue2/dist/index.d.ts +1 -0
- package/vue2/package.json +2 -5
- package/vue2/dist/cypress-vue2.browser.js +0 -20197
| @@ -0,0 +1,213 @@ | |
| 1 | 
            +
             | 
| 2 | 
            +
            /**
         | 
| 3 | 
            +
             * @cypress/svelte v0.0.0-development
         | 
| 4 | 
            +
             * (c) 2022 Cypress.io
         | 
| 5 | 
            +
             * Released under the MIT License
         | 
| 6 | 
            +
             */
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            'use strict';
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            Object.defineProperty(exports, '__esModule', { value: true });
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            const ROOT_SELECTOR = '[data-cy-root]';
         | 
| 13 | 
            +
            const getContainerEl = () => {
         | 
| 14 | 
            +
                const el = document.querySelector(ROOT_SELECTOR);
         | 
| 15 | 
            +
                if (el) {
         | 
| 16 | 
            +
                    return el;
         | 
| 17 | 
            +
                }
         | 
| 18 | 
            +
                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.`);
         | 
| 19 | 
            +
            };
         | 
| 20 | 
            +
            /**
         | 
| 21 | 
            +
             * Remove any style or extra link elements from the iframe placeholder
         | 
| 22 | 
            +
             * left from any previous test
         | 
| 23 | 
            +
             *
         | 
| 24 | 
            +
             */
         | 
| 25 | 
            +
            function cleanupStyles() {
         | 
| 26 | 
            +
                const styles = document.body.querySelectorAll('[data-cy=injected-style-tag]');
         | 
| 27 | 
            +
                styles.forEach((styleElement) => {
         | 
| 28 | 
            +
                    if (styleElement.parentElement) {
         | 
| 29 | 
            +
                        styleElement.parentElement.removeChild(styleElement);
         | 
| 30 | 
            +
                    }
         | 
| 31 | 
            +
                });
         | 
| 32 | 
            +
                const links = document.body.querySelectorAll('[data-cy=injected-stylesheet]');
         | 
| 33 | 
            +
                links.forEach((link) => {
         | 
| 34 | 
            +
                    if (link.parentElement) {
         | 
| 35 | 
            +
                        link.parentElement.removeChild(link);
         | 
| 36 | 
            +
                    }
         | 
| 37 | 
            +
                });
         | 
| 38 | 
            +
            }
         | 
| 39 | 
            +
            /**
         | 
| 40 | 
            +
             * Insert links to external style resources.
         | 
| 41 | 
            +
             */
         | 
| 42 | 
            +
            function insertStylesheets(stylesheets, document, el) {
         | 
| 43 | 
            +
                stylesheets.forEach((href) => {
         | 
| 44 | 
            +
                    const link = document.createElement('link');
         | 
| 45 | 
            +
                    link.type = 'text/css';
         | 
| 46 | 
            +
                    link.rel = 'stylesheet';
         | 
| 47 | 
            +
                    link.href = href;
         | 
| 48 | 
            +
                    link.dataset.cy = 'injected-stylesheet';
         | 
| 49 | 
            +
                    document.body.insertBefore(link, el);
         | 
| 50 | 
            +
                });
         | 
| 51 | 
            +
            }
         | 
| 52 | 
            +
            /**
         | 
| 53 | 
            +
             * Inserts a single stylesheet element
         | 
| 54 | 
            +
             */
         | 
| 55 | 
            +
            function insertStyles(styles, document, el) {
         | 
| 56 | 
            +
                styles.forEach((style) => {
         | 
| 57 | 
            +
                    const styleElement = document.createElement('style');
         | 
| 58 | 
            +
                    styleElement.dataset.cy = 'injected-style-tag';
         | 
| 59 | 
            +
                    styleElement.appendChild(document.createTextNode(style));
         | 
| 60 | 
            +
                    document.body.insertBefore(styleElement, el);
         | 
| 61 | 
            +
                });
         | 
| 62 | 
            +
            }
         | 
| 63 | 
            +
            function insertSingleCssFile(cssFilename, document, el, log) {
         | 
| 64 | 
            +
                return cy.readFile(cssFilename, { log }).then((css) => {
         | 
| 65 | 
            +
                    const style = document.createElement('style');
         | 
| 66 | 
            +
                    style.appendChild(document.createTextNode(css));
         | 
| 67 | 
            +
                    document.body.insertBefore(style, el);
         | 
| 68 | 
            +
                });
         | 
| 69 | 
            +
            }
         | 
| 70 | 
            +
            /**
         | 
| 71 | 
            +
             * Reads the given CSS file from local file system
         | 
| 72 | 
            +
             * and adds the loaded style text as an element.
         | 
| 73 | 
            +
             */
         | 
| 74 | 
            +
            function insertLocalCssFiles(cssFilenames, document, el, log) {
         | 
| 75 | 
            +
                return Cypress.Promise.mapSeries(cssFilenames, (cssFilename) => {
         | 
| 76 | 
            +
                    return insertSingleCssFile(cssFilename, document, el, log);
         | 
| 77 | 
            +
                });
         | 
| 78 | 
            +
            }
         | 
| 79 | 
            +
            /**
         | 
| 80 | 
            +
             * Injects custom style text or CSS file or 3rd party style resources
         | 
| 81 | 
            +
             * into the given document.
         | 
| 82 | 
            +
             */
         | 
| 83 | 
            +
            const injectStylesBeforeElement = (options, document, el) => {
         | 
| 84 | 
            +
                if (!el)
         | 
| 85 | 
            +
                    return;
         | 
| 86 | 
            +
                // first insert all stylesheets as Link elements
         | 
| 87 | 
            +
                let stylesheets = [];
         | 
| 88 | 
            +
                if (typeof options.stylesheet === 'string') {
         | 
| 89 | 
            +
                    stylesheets.push(options.stylesheet);
         | 
| 90 | 
            +
                }
         | 
| 91 | 
            +
                else if (Array.isArray(options.stylesheet)) {
         | 
| 92 | 
            +
                    stylesheets = stylesheets.concat(options.stylesheet);
         | 
| 93 | 
            +
                }
         | 
| 94 | 
            +
                if (typeof options.stylesheets === 'string') {
         | 
| 95 | 
            +
                    options.stylesheets = [options.stylesheets];
         | 
| 96 | 
            +
                }
         | 
| 97 | 
            +
                if (options.stylesheets) {
         | 
| 98 | 
            +
                    stylesheets = stylesheets.concat(options.stylesheets);
         | 
| 99 | 
            +
                }
         | 
| 100 | 
            +
                insertStylesheets(stylesheets, document, el);
         | 
| 101 | 
            +
                // insert any styles as <style>...</style> elements
         | 
| 102 | 
            +
                let styles = [];
         | 
| 103 | 
            +
                if (typeof options.style === 'string') {
         | 
| 104 | 
            +
                    styles.push(options.style);
         | 
| 105 | 
            +
                }
         | 
| 106 | 
            +
                else if (Array.isArray(options.style)) {
         | 
| 107 | 
            +
                    styles = styles.concat(options.style);
         | 
| 108 | 
            +
                }
         | 
| 109 | 
            +
                if (typeof options.styles === 'string') {
         | 
| 110 | 
            +
                    styles.push(options.styles);
         | 
| 111 | 
            +
                }
         | 
| 112 | 
            +
                else if (Array.isArray(options.styles)) {
         | 
| 113 | 
            +
                    styles = styles.concat(options.styles);
         | 
| 114 | 
            +
                }
         | 
| 115 | 
            +
                insertStyles(styles, document, el);
         | 
| 116 | 
            +
                // now load any css files by path and add their content
         | 
| 117 | 
            +
                // as <style>...</style> elements
         | 
| 118 | 
            +
                let cssFiles = [];
         | 
| 119 | 
            +
                if (typeof options.cssFile === 'string') {
         | 
| 120 | 
            +
                    cssFiles.push(options.cssFile);
         | 
| 121 | 
            +
                }
         | 
| 122 | 
            +
                else if (Array.isArray(options.cssFile)) {
         | 
| 123 | 
            +
                    cssFiles = cssFiles.concat(options.cssFile);
         | 
| 124 | 
            +
                }
         | 
| 125 | 
            +
                if (typeof options.cssFiles === 'string') {
         | 
| 126 | 
            +
                    cssFiles.push(options.cssFiles);
         | 
| 127 | 
            +
                }
         | 
| 128 | 
            +
                else if (Array.isArray(options.cssFiles)) {
         | 
| 129 | 
            +
                    cssFiles = cssFiles.concat(options.cssFiles);
         | 
| 130 | 
            +
                }
         | 
| 131 | 
            +
                return insertLocalCssFiles(cssFiles, document, el, options.log);
         | 
| 132 | 
            +
            };
         | 
| 133 | 
            +
            function setupHooks(optionalCallback) {
         | 
| 134 | 
            +
                // Consumed by the framework "mount" libs. A user might register their own mount in the scaffolded 'commands.js'
         | 
| 135 | 
            +
                // file that is imported by e2e and component support files by default. We don't want CT side effects to run when e2e
         | 
| 136 | 
            +
                // testing so we early return.
         | 
| 137 | 
            +
                // System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
         | 
| 138 | 
            +
                if (Cypress.testingType !== 'component') {
         | 
| 139 | 
            +
                    return;
         | 
| 140 | 
            +
                }
         | 
| 141 | 
            +
                // When running component specs, we cannot allow "cy.visit"
         | 
| 142 | 
            +
                // because it will wipe out our preparation work, and does not make much sense
         | 
| 143 | 
            +
                // thus we overwrite "cy.visit" to throw an error
         | 
| 144 | 
            +
                Cypress.Commands.overwrite('visit', () => {
         | 
| 145 | 
            +
                    throw new Error('cy.visit from a component spec is not allowed');
         | 
| 146 | 
            +
                });
         | 
| 147 | 
            +
                // @ts-ignore
         | 
| 148 | 
            +
                Cypress.on('test:before:run', () => {
         | 
| 149 | 
            +
                    optionalCallback === null || optionalCallback === void 0 ? void 0 : optionalCallback();
         | 
| 150 | 
            +
                    cleanupStyles();
         | 
| 151 | 
            +
                });
         | 
| 152 | 
            +
            }
         | 
| 153 | 
            +
             | 
| 154 | 
            +
            const DEFAULT_COMP_NAME = 'unknown';
         | 
| 155 | 
            +
            let componentInstance;
         | 
| 156 | 
            +
            const cleanup = () => {
         | 
| 157 | 
            +
                componentInstance === null || componentInstance === void 0 ? void 0 : componentInstance.$destroy();
         | 
| 158 | 
            +
            };
         | 
| 159 | 
            +
            // Extract the component name from the object passed to mount
         | 
| 160 | 
            +
            const getComponentDisplayName = (Component) => {
         | 
| 161 | 
            +
                if (Component.name) {
         | 
| 162 | 
            +
                    const [_, match] = /Proxy\<(\w+)\>/.exec(Component.name) || [];
         | 
| 163 | 
            +
                    return match || Component.name;
         | 
| 164 | 
            +
                }
         | 
| 165 | 
            +
                return DEFAULT_COMP_NAME;
         | 
| 166 | 
            +
            };
         | 
| 167 | 
            +
            /**
         | 
| 168 | 
            +
             * Mounts a Svelte component inside the Cypress browser
         | 
| 169 | 
            +
             *
         | 
| 170 | 
            +
             * @param {SvelteConstructor<T>} Component Svelte component being mounted
         | 
| 171 | 
            +
             * @param {MountReturn<T extends SvelteComponent>} options options to customize the component being mounted
         | 
| 172 | 
            +
             * @returns Cypress.Chainable<MountReturn>
         | 
| 173 | 
            +
             *
         | 
| 174 | 
            +
             * @example
         | 
| 175 | 
            +
             * import Counter from './Counter.svelte'
         | 
| 176 | 
            +
             * import { mount } from 'cypress/svelte'
         | 
| 177 | 
            +
             *
         | 
| 178 | 
            +
             * it('should render', () => {
         | 
| 179 | 
            +
             *   mount(Counter, { props: { count: 42 } })
         | 
| 180 | 
            +
             *   cy.get('button').contains(42)
         | 
| 181 | 
            +
             * })
         | 
| 182 | 
            +
             */
         | 
| 183 | 
            +
            function mount(Component, options = {}) {
         | 
| 184 | 
            +
                return cy.then(() => {
         | 
| 185 | 
            +
                    const target = getContainerEl();
         | 
| 186 | 
            +
                    injectStylesBeforeElement(options, document, target);
         | 
| 187 | 
            +
                    const ComponentConstructor = (Component.default || Component);
         | 
| 188 | 
            +
                    componentInstance = new ComponentConstructor(Object.assign({ target }, options));
         | 
| 189 | 
            +
                    // by waiting, we are delaying test execution for the next tick of event loop
         | 
| 190 | 
            +
                    // and letting hooks and component lifecycle methods to execute mount
         | 
| 191 | 
            +
                    return cy.wait(0, { log: false }).then(() => {
         | 
| 192 | 
            +
                        if (options.log !== false) {
         | 
| 193 | 
            +
                            const mountMessage = `<${getComponentDisplayName(Component)} ... />`;
         | 
| 194 | 
            +
                            Cypress.log({
         | 
| 195 | 
            +
                                name: 'mount',
         | 
| 196 | 
            +
                                message: [mountMessage],
         | 
| 197 | 
            +
                            }).snapshot('mounted').end();
         | 
| 198 | 
            +
                        }
         | 
| 199 | 
            +
                    })
         | 
| 200 | 
            +
                        .wrap({ component: componentInstance }, { log: false });
         | 
| 201 | 
            +
                });
         | 
| 202 | 
            +
            }
         | 
| 203 | 
            +
            // Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
         | 
| 204 | 
            +
            // by creating an explicit function/import that the user can register in their 'component.js' support file,
         | 
| 205 | 
            +
            // such as:
         | 
| 206 | 
            +
            //    import 'cypress/<my-framework>/support'
         | 
| 207 | 
            +
            // or
         | 
| 208 | 
            +
            //    import { registerCT } from 'cypress/<my-framework>'
         | 
| 209 | 
            +
            //    registerCT()
         | 
| 210 | 
            +
            // Note: This would be a breaking change
         | 
| 211 | 
            +
            setupHooks(cleanup);
         | 
| 212 | 
            +
             | 
| 213 | 
            +
            exports.mount = mount;
         | 
| @@ -0,0 +1,209 @@ | |
| 1 | 
            +
             | 
| 2 | 
            +
            /**
         | 
| 3 | 
            +
             * @cypress/svelte v0.0.0-development
         | 
| 4 | 
            +
             * (c) 2022 Cypress.io
         | 
| 5 | 
            +
             * Released under the MIT License
         | 
| 6 | 
            +
             */
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            const ROOT_SELECTOR = '[data-cy-root]';
         | 
| 9 | 
            +
            const getContainerEl = () => {
         | 
| 10 | 
            +
                const el = document.querySelector(ROOT_SELECTOR);
         | 
| 11 | 
            +
                if (el) {
         | 
| 12 | 
            +
                    return el;
         | 
| 13 | 
            +
                }
         | 
| 14 | 
            +
                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.`);
         | 
| 15 | 
            +
            };
         | 
| 16 | 
            +
            /**
         | 
| 17 | 
            +
             * Remove any style or extra link elements from the iframe placeholder
         | 
| 18 | 
            +
             * left from any previous test
         | 
| 19 | 
            +
             *
         | 
| 20 | 
            +
             */
         | 
| 21 | 
            +
            function cleanupStyles() {
         | 
| 22 | 
            +
                const styles = document.body.querySelectorAll('[data-cy=injected-style-tag]');
         | 
| 23 | 
            +
                styles.forEach((styleElement) => {
         | 
| 24 | 
            +
                    if (styleElement.parentElement) {
         | 
| 25 | 
            +
                        styleElement.parentElement.removeChild(styleElement);
         | 
| 26 | 
            +
                    }
         | 
| 27 | 
            +
                });
         | 
| 28 | 
            +
                const links = document.body.querySelectorAll('[data-cy=injected-stylesheet]');
         | 
| 29 | 
            +
                links.forEach((link) => {
         | 
| 30 | 
            +
                    if (link.parentElement) {
         | 
| 31 | 
            +
                        link.parentElement.removeChild(link);
         | 
| 32 | 
            +
                    }
         | 
| 33 | 
            +
                });
         | 
| 34 | 
            +
            }
         | 
| 35 | 
            +
            /**
         | 
| 36 | 
            +
             * Insert links to external style resources.
         | 
| 37 | 
            +
             */
         | 
| 38 | 
            +
            function insertStylesheets(stylesheets, document, el) {
         | 
| 39 | 
            +
                stylesheets.forEach((href) => {
         | 
| 40 | 
            +
                    const link = document.createElement('link');
         | 
| 41 | 
            +
                    link.type = 'text/css';
         | 
| 42 | 
            +
                    link.rel = 'stylesheet';
         | 
| 43 | 
            +
                    link.href = href;
         | 
| 44 | 
            +
                    link.dataset.cy = 'injected-stylesheet';
         | 
| 45 | 
            +
                    document.body.insertBefore(link, el);
         | 
| 46 | 
            +
                });
         | 
| 47 | 
            +
            }
         | 
| 48 | 
            +
            /**
         | 
| 49 | 
            +
             * Inserts a single stylesheet element
         | 
| 50 | 
            +
             */
         | 
| 51 | 
            +
            function insertStyles(styles, document, el) {
         | 
| 52 | 
            +
                styles.forEach((style) => {
         | 
| 53 | 
            +
                    const styleElement = document.createElement('style');
         | 
| 54 | 
            +
                    styleElement.dataset.cy = 'injected-style-tag';
         | 
| 55 | 
            +
                    styleElement.appendChild(document.createTextNode(style));
         | 
| 56 | 
            +
                    document.body.insertBefore(styleElement, el);
         | 
| 57 | 
            +
                });
         | 
| 58 | 
            +
            }
         | 
| 59 | 
            +
            function insertSingleCssFile(cssFilename, document, el, log) {
         | 
| 60 | 
            +
                return cy.readFile(cssFilename, { log }).then((css) => {
         | 
| 61 | 
            +
                    const style = document.createElement('style');
         | 
| 62 | 
            +
                    style.appendChild(document.createTextNode(css));
         | 
| 63 | 
            +
                    document.body.insertBefore(style, el);
         | 
| 64 | 
            +
                });
         | 
| 65 | 
            +
            }
         | 
| 66 | 
            +
            /**
         | 
| 67 | 
            +
             * Reads the given CSS file from local file system
         | 
| 68 | 
            +
             * and adds the loaded style text as an element.
         | 
| 69 | 
            +
             */
         | 
| 70 | 
            +
            function insertLocalCssFiles(cssFilenames, document, el, log) {
         | 
| 71 | 
            +
                return Cypress.Promise.mapSeries(cssFilenames, (cssFilename) => {
         | 
| 72 | 
            +
                    return insertSingleCssFile(cssFilename, document, el, log);
         | 
| 73 | 
            +
                });
         | 
| 74 | 
            +
            }
         | 
| 75 | 
            +
            /**
         | 
| 76 | 
            +
             * Injects custom style text or CSS file or 3rd party style resources
         | 
| 77 | 
            +
             * into the given document.
         | 
| 78 | 
            +
             */
         | 
| 79 | 
            +
            const injectStylesBeforeElement = (options, document, el) => {
         | 
| 80 | 
            +
                if (!el)
         | 
| 81 | 
            +
                    return;
         | 
| 82 | 
            +
                // first insert all stylesheets as Link elements
         | 
| 83 | 
            +
                let stylesheets = [];
         | 
| 84 | 
            +
                if (typeof options.stylesheet === 'string') {
         | 
| 85 | 
            +
                    stylesheets.push(options.stylesheet);
         | 
| 86 | 
            +
                }
         | 
| 87 | 
            +
                else if (Array.isArray(options.stylesheet)) {
         | 
| 88 | 
            +
                    stylesheets = stylesheets.concat(options.stylesheet);
         | 
| 89 | 
            +
                }
         | 
| 90 | 
            +
                if (typeof options.stylesheets === 'string') {
         | 
| 91 | 
            +
                    options.stylesheets = [options.stylesheets];
         | 
| 92 | 
            +
                }
         | 
| 93 | 
            +
                if (options.stylesheets) {
         | 
| 94 | 
            +
                    stylesheets = stylesheets.concat(options.stylesheets);
         | 
| 95 | 
            +
                }
         | 
| 96 | 
            +
                insertStylesheets(stylesheets, document, el);
         | 
| 97 | 
            +
                // insert any styles as <style>...</style> elements
         | 
| 98 | 
            +
                let styles = [];
         | 
| 99 | 
            +
                if (typeof options.style === 'string') {
         | 
| 100 | 
            +
                    styles.push(options.style);
         | 
| 101 | 
            +
                }
         | 
| 102 | 
            +
                else if (Array.isArray(options.style)) {
         | 
| 103 | 
            +
                    styles = styles.concat(options.style);
         | 
| 104 | 
            +
                }
         | 
| 105 | 
            +
                if (typeof options.styles === 'string') {
         | 
| 106 | 
            +
                    styles.push(options.styles);
         | 
| 107 | 
            +
                }
         | 
| 108 | 
            +
                else if (Array.isArray(options.styles)) {
         | 
| 109 | 
            +
                    styles = styles.concat(options.styles);
         | 
| 110 | 
            +
                }
         | 
| 111 | 
            +
                insertStyles(styles, document, el);
         | 
| 112 | 
            +
                // now load any css files by path and add their content
         | 
| 113 | 
            +
                // as <style>...</style> elements
         | 
| 114 | 
            +
                let cssFiles = [];
         | 
| 115 | 
            +
                if (typeof options.cssFile === 'string') {
         | 
| 116 | 
            +
                    cssFiles.push(options.cssFile);
         | 
| 117 | 
            +
                }
         | 
| 118 | 
            +
                else if (Array.isArray(options.cssFile)) {
         | 
| 119 | 
            +
                    cssFiles = cssFiles.concat(options.cssFile);
         | 
| 120 | 
            +
                }
         | 
| 121 | 
            +
                if (typeof options.cssFiles === 'string') {
         | 
| 122 | 
            +
                    cssFiles.push(options.cssFiles);
         | 
| 123 | 
            +
                }
         | 
| 124 | 
            +
                else if (Array.isArray(options.cssFiles)) {
         | 
| 125 | 
            +
                    cssFiles = cssFiles.concat(options.cssFiles);
         | 
| 126 | 
            +
                }
         | 
| 127 | 
            +
                return insertLocalCssFiles(cssFiles, document, el, options.log);
         | 
| 128 | 
            +
            };
         | 
| 129 | 
            +
            function setupHooks(optionalCallback) {
         | 
| 130 | 
            +
                // Consumed by the framework "mount" libs. A user might register their own mount in the scaffolded 'commands.js'
         | 
| 131 | 
            +
                // file that is imported by e2e and component support files by default. We don't want CT side effects to run when e2e
         | 
| 132 | 
            +
                // testing so we early return.
         | 
| 133 | 
            +
                // System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
         | 
| 134 | 
            +
                if (Cypress.testingType !== 'component') {
         | 
| 135 | 
            +
                    return;
         | 
| 136 | 
            +
                }
         | 
| 137 | 
            +
                // When running component specs, we cannot allow "cy.visit"
         | 
| 138 | 
            +
                // because it will wipe out our preparation work, and does not make much sense
         | 
| 139 | 
            +
                // thus we overwrite "cy.visit" to throw an error
         | 
| 140 | 
            +
                Cypress.Commands.overwrite('visit', () => {
         | 
| 141 | 
            +
                    throw new Error('cy.visit from a component spec is not allowed');
         | 
| 142 | 
            +
                });
         | 
| 143 | 
            +
                // @ts-ignore
         | 
| 144 | 
            +
                Cypress.on('test:before:run', () => {
         | 
| 145 | 
            +
                    optionalCallback === null || optionalCallback === void 0 ? void 0 : optionalCallback();
         | 
| 146 | 
            +
                    cleanupStyles();
         | 
| 147 | 
            +
                });
         | 
| 148 | 
            +
            }
         | 
| 149 | 
            +
             | 
| 150 | 
            +
            const DEFAULT_COMP_NAME = 'unknown';
         | 
| 151 | 
            +
            let componentInstance;
         | 
| 152 | 
            +
            const cleanup = () => {
         | 
| 153 | 
            +
                componentInstance === null || componentInstance === void 0 ? void 0 : componentInstance.$destroy();
         | 
| 154 | 
            +
            };
         | 
| 155 | 
            +
            // Extract the component name from the object passed to mount
         | 
| 156 | 
            +
            const getComponentDisplayName = (Component) => {
         | 
| 157 | 
            +
                if (Component.name) {
         | 
| 158 | 
            +
                    const [_, match] = /Proxy\<(\w+)\>/.exec(Component.name) || [];
         | 
| 159 | 
            +
                    return match || Component.name;
         | 
| 160 | 
            +
                }
         | 
| 161 | 
            +
                return DEFAULT_COMP_NAME;
         | 
| 162 | 
            +
            };
         | 
| 163 | 
            +
            /**
         | 
| 164 | 
            +
             * Mounts a Svelte component inside the Cypress browser
         | 
| 165 | 
            +
             *
         | 
| 166 | 
            +
             * @param {SvelteConstructor<T>} Component Svelte component being mounted
         | 
| 167 | 
            +
             * @param {MountReturn<T extends SvelteComponent>} options options to customize the component being mounted
         | 
| 168 | 
            +
             * @returns Cypress.Chainable<MountReturn>
         | 
| 169 | 
            +
             *
         | 
| 170 | 
            +
             * @example
         | 
| 171 | 
            +
             * import Counter from './Counter.svelte'
         | 
| 172 | 
            +
             * import { mount } from 'cypress/svelte'
         | 
| 173 | 
            +
             *
         | 
| 174 | 
            +
             * it('should render', () => {
         | 
| 175 | 
            +
             *   mount(Counter, { props: { count: 42 } })
         | 
| 176 | 
            +
             *   cy.get('button').contains(42)
         | 
| 177 | 
            +
             * })
         | 
| 178 | 
            +
             */
         | 
| 179 | 
            +
            function mount(Component, options = {}) {
         | 
| 180 | 
            +
                return cy.then(() => {
         | 
| 181 | 
            +
                    const target = getContainerEl();
         | 
| 182 | 
            +
                    injectStylesBeforeElement(options, document, target);
         | 
| 183 | 
            +
                    const ComponentConstructor = (Component.default || Component);
         | 
| 184 | 
            +
                    componentInstance = new ComponentConstructor(Object.assign({ target }, options));
         | 
| 185 | 
            +
                    // by waiting, we are delaying test execution for the next tick of event loop
         | 
| 186 | 
            +
                    // and letting hooks and component lifecycle methods to execute mount
         | 
| 187 | 
            +
                    return cy.wait(0, { log: false }).then(() => {
         | 
| 188 | 
            +
                        if (options.log !== false) {
         | 
| 189 | 
            +
                            const mountMessage = `<${getComponentDisplayName(Component)} ... />`;
         | 
| 190 | 
            +
                            Cypress.log({
         | 
| 191 | 
            +
                                name: 'mount',
         | 
| 192 | 
            +
                                message: [mountMessage],
         | 
| 193 | 
            +
                            }).snapshot('mounted').end();
         | 
| 194 | 
            +
                        }
         | 
| 195 | 
            +
                    })
         | 
| 196 | 
            +
                        .wrap({ component: componentInstance }, { log: false });
         | 
| 197 | 
            +
                });
         | 
| 198 | 
            +
            }
         | 
| 199 | 
            +
            // Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
         | 
| 200 | 
            +
            // by creating an explicit function/import that the user can register in their 'component.js' support file,
         | 
| 201 | 
            +
            // such as:
         | 
| 202 | 
            +
            //    import 'cypress/<my-framework>/support'
         | 
| 203 | 
            +
            // or
         | 
| 204 | 
            +
            //    import { registerCT } from 'cypress/<my-framework>'
         | 
| 205 | 
            +
            //    registerCT()
         | 
| 206 | 
            +
            // Note: This would be a breaking change
         | 
| 207 | 
            +
            setupHooks(cleanup);
         | 
| 208 | 
            +
             | 
| 209 | 
            +
            export { mount };
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            export * from './mount';
         | 
| @@ -0,0 +1,30 @@ | |
| 1 | 
            +
            /// <reference types="cypress" />
         | 
| 2 | 
            +
            /// <reference types="cypress" />
         | 
| 3 | 
            +
            import { StyleOptions } from '@cypress/mount-utils';
         | 
| 4 | 
            +
            import type { ComponentConstructorOptions, ComponentProps, SvelteComponent } from 'svelte';
         | 
| 5 | 
            +
            declare type SvelteConstructor<T> = new (...args: any[]) => T;
         | 
| 6 | 
            +
            declare type SvelteComponentOptions<T extends SvelteComponent> = Omit<ComponentConstructorOptions<ComponentProps<T>>, 'hydrate' | 'target' | '$$inline'>;
         | 
| 7 | 
            +
            export interface MountOptions<T extends SvelteComponent> extends SvelteComponentOptions<T>, Partial<StyleOptions> {
         | 
| 8 | 
            +
                log?: boolean;
         | 
| 9 | 
            +
            }
         | 
| 10 | 
            +
            export interface MountReturn<T extends SvelteComponent> {
         | 
| 11 | 
            +
                component: T;
         | 
| 12 | 
            +
            }
         | 
| 13 | 
            +
            /**
         | 
| 14 | 
            +
             * Mounts a Svelte component inside the Cypress browser
         | 
| 15 | 
            +
             *
         | 
| 16 | 
            +
             * @param {SvelteConstructor<T>} Component Svelte component being mounted
         | 
| 17 | 
            +
             * @param {MountReturn<T extends SvelteComponent>} options options to customize the component being mounted
         | 
| 18 | 
            +
             * @returns Cypress.Chainable<MountReturn>
         | 
| 19 | 
            +
             *
         | 
| 20 | 
            +
             * @example
         | 
| 21 | 
            +
             * import Counter from './Counter.svelte'
         | 
| 22 | 
            +
             * import { mount } from 'cypress/svelte'
         | 
| 23 | 
            +
             *
         | 
| 24 | 
            +
             * it('should render', () => {
         | 
| 25 | 
            +
             *   mount(Counter, { props: { count: 42 } })
         | 
| 26 | 
            +
             *   cy.get('button').contains(42)
         | 
| 27 | 
            +
             * })
         | 
| 28 | 
            +
             */
         | 
| 29 | 
            +
            export declare function mount<T extends SvelteComponent>(Component: SvelteConstructor<T>, options?: MountOptions<T>): Cypress.Chainable<MountReturn<T>>;
         | 
| 30 | 
            +
            export {};
         | 
| @@ -0,0 +1,43 @@ | |
| 1 | 
            +
            {
         | 
| 2 | 
            +
              "name": "@cypress/svelte",
         | 
| 3 | 
            +
              "version": "0.0.0-development",
         | 
| 4 | 
            +
              "description": "Browser-based Component Testing for Svelte.js with Cypress.io 🧡",
         | 
| 5 | 
            +
              "main": "dist/cypress-svelte.cjs.js",
         | 
| 6 | 
            +
              "scripts": {
         | 
| 7 | 
            +
                "prebuild": "rimraf dist",
         | 
| 8 | 
            +
                "build": "rollup -c rollup.config.mjs",
         | 
| 9 | 
            +
                "postbuild": "node ../../scripts/sync-exported-npm-with-cli.js",
         | 
| 10 | 
            +
                "build-prod": "yarn build",
         | 
| 11 | 
            +
                "check-ts": "tsc --noEmit"
         | 
| 12 | 
            +
              },
         | 
| 13 | 
            +
              "devDependencies": {
         | 
| 14 | 
            +
                "@cypress/mount-utils": "0.0.0-development",
         | 
| 15 | 
            +
                "svelte": "^3.49.0",
         | 
| 16 | 
            +
                "typescript": "^4.7.4"
         | 
| 17 | 
            +
              },
         | 
| 18 | 
            +
              "peerDependencies": {
         | 
| 19 | 
            +
                "cypress": ">=10.6.0",
         | 
| 20 | 
            +
                "svelte": ">=3.0.0"
         | 
| 21 | 
            +
              },
         | 
| 22 | 
            +
              "files": [
         | 
| 23 | 
            +
                "dist/**/*"
         | 
| 24 | 
            +
              ],
         | 
| 25 | 
            +
              "types": "dist/index.d.ts",
         | 
| 26 | 
            +
              "license": "MIT",
         | 
| 27 | 
            +
              "repository": {
         | 
| 28 | 
            +
                "type": "git",
         | 
| 29 | 
            +
                "url": "https://github.com/cypress-io/cypress.git"
         | 
| 30 | 
            +
              },
         | 
| 31 | 
            +
              "homepage": "https://github.com/cypress-io/cypress/blob/master/npm/svelte/#readme",
         | 
| 32 | 
            +
              "bugs": "https://github.com/cypress-io/cypress/issues/new?assignees=&labels=npm%3A%20%40cypress%2Fsvelte&template=1-bug-report.md&title=",
         | 
| 33 | 
            +
              "keywords": [
         | 
| 34 | 
            +
                "cypress",
         | 
| 35 | 
            +
                "svelte",
         | 
| 36 | 
            +
                "testing",
         | 
| 37 | 
            +
                "component testing"
         | 
| 38 | 
            +
              ],
         | 
| 39 | 
            +
              "module": "dist/cypress-svelte.esm-bundler.js",
         | 
| 40 | 
            +
              "publishConfig": {
         | 
| 41 | 
            +
                "access": "public"
         | 
| 42 | 
            +
              }
         | 
| 43 | 
            +
            }
         | 
    
        package/types/cypress.d.ts
    CHANGED
    
    | @@ -1,5 +1,6 @@ | |
| 1 1 | 
             
            /// <reference path="./cypress-npm-api.d.ts" />
         | 
| 2 2 | 
             
            /// <reference path="./cypress-eventemitter.d.ts" />
         | 
| 3 | 
            +
            /// <reference path="./cypress-type-helpers.d.ts" />
         | 
| 3 4 |  | 
| 4 5 | 
             
            declare namespace Cypress {
         | 
| 5 6 | 
             
              type FileContents = string | any[] | object
         | 
| @@ -81,7 +82,7 @@ declare namespace Cypress { | |
| 81 82 |  | 
| 82 83 | 
             
              type BrowserChannel = 'stable' | 'canary' | 'beta' | 'dev' | 'nightly' | string
         | 
| 83 84 |  | 
| 84 | 
            -
              type BrowserFamily = 'chromium' | 'firefox'
         | 
| 85 | 
            +
              type BrowserFamily = 'chromium' | 'firefox' | 'webkit'
         | 
| 85 86 |  | 
| 86 87 | 
             
              /**
         | 
| 87 88 | 
             
               * Describes a browser Cypress can control
         | 
| @@ -2719,6 +2720,13 @@ declare namespace Cypress { | |
| 2719 2720 | 
             
                 * @default 60000
         | 
| 2720 2721 | 
             
                 */
         | 
| 2721 2722 | 
             
                pageLoadTimeout: number
         | 
| 2723 | 
            +
                /**
         | 
| 2724 | 
            +
                 * Whether Cypress will search for and replace
         | 
| 2725 | 
            +
                 * obstructive JS code in .js or .html files.
         | 
| 2726 | 
            +
                 *
         | 
| 2727 | 
            +
                 * @see https://on.cypress.io/configuration#modifyObstructiveCode
         | 
| 2728 | 
            +
                 */
         | 
| 2729 | 
            +
                modifyObstructiveCode: boolean
         | 
| 2722 2730 | 
             
                /**
         | 
| 2723 2731 | 
             
                 * Time, in milliseconds, to wait for an XHR request to go out in a [cy.wait()](https://on.cypress.io/wait) command
         | 
| 2724 2732 | 
             
                 * @default 5000
         | 
| @@ -2866,10 +2874,20 @@ declare namespace Cypress { | |
| 2866 2874 | 
             
                 */
         | 
| 2867 2875 | 
             
                experimentalModifyObstructiveThirdPartyCode: boolean
         | 
| 2868 2876 | 
             
                /**
         | 
| 2869 | 
            -
                 *  | 
| 2877 | 
            +
                 * Enables AST-based JS/HTML rewriting. This may fix issues caused by the existing regex-based JS/HTML replacement algorithm.
         | 
| 2870 2878 | 
             
                 * @default false
         | 
| 2871 2879 | 
             
                 */
         | 
| 2872 2880 | 
             
                experimentalSourceRewriting: boolean
         | 
| 2881 | 
            +
                /**
         | 
| 2882 | 
            +
                 * Generate and save commands directly to your test suite by interacting with your app as an end user would.
         | 
| 2883 | 
            +
                 * @default false
         | 
| 2884 | 
            +
                 */
         | 
| 2885 | 
            +
                experimentalStudio: boolean
         | 
| 2886 | 
            +
                /**
         | 
| 2887 | 
            +
                 * Adds support for testing in the WebKit browser engine used by Safari. See https://on.cypress.io/webkit-experiment for more information.
         | 
| 2888 | 
            +
                 * @default false
         | 
| 2889 | 
            +
                 */
         | 
| 2890 | 
            +
                experimentalWebKitSupport: boolean
         | 
| 2873 2891 | 
             
                /**
         | 
| 2874 2892 | 
             
                 * Number of times to retry a failed test.
         | 
| 2875 2893 | 
             
                 * If a number is set, tests will retry in both runMode and openMode.
         | 
| @@ -2962,13 +2980,6 @@ declare namespace Cypress { | |
| 2962 2980 | 
             
                 * Whether Cypress was launched via 'cypress open' (interactive mode)
         | 
| 2963 2981 | 
             
                 */
         | 
| 2964 2982 | 
             
                isInteractive: boolean
         | 
| 2965 | 
            -
                /**
         | 
| 2966 | 
            -
                 * Whether Cypress will search for and replace
         | 
| 2967 | 
            -
                 * obstructive JS code in .js or .html files.
         | 
| 2968 | 
            -
                 *
         | 
| 2969 | 
            -
                 * @see https://on.cypress.io/configuration#modifyObstructiveCode
         | 
| 2970 | 
            -
                 */
         | 
| 2971 | 
            -
                modifyObstructiveCode: boolean
         | 
| 2972 2983 | 
             
                /**
         | 
| 2973 2984 | 
             
                 * The platform Cypress is running on.
         | 
| 2974 2985 | 
             
                 */
         | 
| @@ -3047,21 +3058,39 @@ declare namespace Cypress { | |
| 3047 3058 |  | 
| 3048 3059 | 
             
              type PickConfigOpt<T> = T extends keyof DefineDevServerConfig ? DefineDevServerConfig[T] : any
         | 
| 3049 3060 |  | 
| 3061 | 
            +
              interface AngularDevServerProjectConfig {
         | 
| 3062 | 
            +
                root: string,
         | 
| 3063 | 
            +
                sourceRoot: string,
         | 
| 3064 | 
            +
                buildOptions: Record<string, any>
         | 
| 3065 | 
            +
              }
         | 
| 3066 | 
            +
             | 
| 3050 3067 | 
             
              type DevServerFn<ComponentDevServerOpts = any> = (cypressDevServerConfig: DevServerConfig, devServerConfig: ComponentDevServerOpts) => ResolvedDevServerConfig | Promise<ResolvedDevServerConfig>
         | 
| 3051 3068 |  | 
| 3052 3069 | 
             
              type DevServerConfigOptions = {
         | 
| 3053 3070 | 
             
                bundler: 'webpack'
         | 
| 3054 | 
            -
                framework: 'react' | 'vue' | 'vue-cli' | 'nuxt' | 'create-react-app' | 'next' | ' | 
| 3071 | 
            +
                framework: 'react' | 'vue' | 'vue-cli' | 'nuxt' | 'create-react-app' | 'next' | 'svelte'
         | 
| 3055 3072 | 
             
                webpackConfig?: PickConfigOpt<'webpackConfig'>
         | 
| 3056 3073 | 
             
              } | {
         | 
| 3057 3074 | 
             
                bundler: 'vite'
         | 
| 3058 | 
            -
                framework: 'react' | 'vue'
         | 
| 3075 | 
            +
                framework: 'react' | 'vue' | 'svelte'
         | 
| 3059 3076 | 
             
                viteConfig?: Omit<Exclude<PickConfigOpt<'viteConfig'>, undefined>, 'base' | 'root'>
         | 
| 3077 | 
            +
              } | {
         | 
| 3078 | 
            +
                bundler: 'webpack',
         | 
| 3079 | 
            +
                framework: 'angular',
         | 
| 3080 | 
            +
                webpackConfig?: PickConfigOpt<'webpackConfig'>,
         | 
| 3081 | 
            +
                options?: {
         | 
| 3082 | 
            +
                  projectConfig: AngularDevServerProjectConfig
         | 
| 3083 | 
            +
                }
         | 
| 3060 3084 | 
             
              }
         | 
| 3061 3085 |  | 
| 3062 | 
            -
              interface ComponentConfigOptions<ComponentDevServerOpts = any> extends Omit<CoreConfigOptions, 'baseUrl' | 'experimentalSessionAndOrigin'> {
         | 
| 3086 | 
            +
              interface ComponentConfigOptions<ComponentDevServerOpts = any> extends Omit<CoreConfigOptions, 'baseUrl' | 'experimentalSessionAndOrigin' | 'experimentalStudio'> {
         | 
| 3063 3087 | 
             
                devServer: DevServerFn<ComponentDevServerOpts> | DevServerConfigOptions
         | 
| 3064 3088 | 
             
                devServerConfig?: ComponentDevServerOpts
         | 
| 3089 | 
            +
                /**
         | 
| 3090 | 
            +
                 * Runs all component specs in a single tab, trading spec isolation for faster run mode execution.
         | 
| 3091 | 
            +
                 * @default false
         | 
| 3092 | 
            +
                 */
         | 
| 3093 | 
            +
                experimentalSingleTabRunMode?: boolean
         | 
| 3065 3094 | 
             
              }
         | 
| 3066 3095 |  | 
| 3067 3096 | 
             
              /**
         | 
| @@ -5778,6 +5807,26 @@ declare namespace Cypress { | |
| 5778 5807 | 
             
                 *   cy.clock().invoke('restore')
         | 
| 5779 5808 | 
             
                 */
         | 
| 5780 5809 | 
             
                restore(): void
         | 
| 5810 | 
            +
                /**
         | 
| 5811 | 
            +
                 * Change the time without invoking any timers.
         | 
| 5812 | 
            +
                 *
         | 
| 5813 | 
            +
                 * Default value with no argument or undefined is 0.
         | 
| 5814 | 
            +
                 *
         | 
| 5815 | 
            +
                 * This can be useful if you need to change the time by an hour
         | 
| 5816 | 
            +
                 * while there is a setInterval registered that may otherwise run thousands
         | 
| 5817 | 
            +
                 * of times.
         | 
| 5818 | 
            +
                 * @see https://on.cypress.io/clock
         | 
| 5819 | 
            +
                 * @example
         | 
| 5820 | 
            +
                 *   cy.clock()
         | 
| 5821 | 
            +
                 *   cy.visit('/')
         | 
| 5822 | 
            +
                 *   ...
         | 
| 5823 | 
            +
                 *   cy.clock().then(clock => {
         | 
| 5824 | 
            +
                 *     clock.setSystemTime(60 * 60 * 1000)
         | 
| 5825 | 
            +
                 *   })
         | 
| 5826 | 
            +
                 *   // or use this shortcut
         | 
| 5827 | 
            +
                 *   cy.clock().invoke('setSystemTime', 60 * 60 * 1000)
         | 
| 5828 | 
            +
                 */
         | 
| 5829 | 
            +
                setSystemTime(now?: number | Date): void
         | 
| 5781 5830 | 
             
              }
         | 
| 5782 5831 |  | 
| 5783 5832 | 
             
              interface Cookie {
         | 
    
        package/vue/CHANGELOG.md
    CHANGED
    
    | @@ -1,3 +1,10 @@ | |
| 1 | 
            +
            # [@cypress/vue-v4.2.0](https://github.com/cypress-io/cypress/compare/@cypress/vue-v4.1.0...@cypress/vue-v4.2.0) (2022-08-30)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
             | 
| 4 | 
            +
            ### Features
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
         | 
| 7 | 
            +
             | 
| 1 8 | 
             
            # [@cypress/vue-v4.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vue-v4.0.0...@cypress/vue-v4.1.0) (2022-08-11)
         | 
| 2 9 |  | 
| 3 10 |  |