cypress 10.4.0 → 10.7.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 +86 -0
- package/angular/README.md +85 -0
- package/angular/dist/index.d.ts +1 -0
- package/angular/dist/index.js +265 -0
- package/angular/dist/mount.d.ts +112 -0
- package/angular/package.json +68 -0
- package/lib/tasks/download.js +4 -3
- package/mount-utils/CHANGELOG.md +7 -0
- package/mount-utils/package.json +5 -1
- package/package.json +16 -4
- package/react/CHANGELOG.md +20 -0
- package/react/dist/createMount.d.ts +7 -6
- package/react/dist/cypress-react.cjs.js +653 -140
- package/react/dist/cypress-react.esm-bundler.js +640 -127
- package/react/dist/mount.d.ts +2 -1
- package/react/dist/mountHook.d.ts +1 -0
- package/react/dist/types.d.ts +2 -7
- package/react/package.json +4 -6
- package/react18/CHANGELOG.md +13 -0
- package/react18/dist/cypress-react.cjs.js +300 -118
- package/react18/dist/cypress-react.esm-bundler.js +286 -104
- package/react18/dist/index.d.ts +2 -1
- package/react18/package.json +2 -2
- package/svelte/CHANGELOG.md +0 -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 -5
- package/vue/CHANGELOG.md +14 -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 +2 -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) {
|
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) {
|
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
|
@@ -2784,6 +2785,13 @@ declare namespace Cypress {
|
|
2784
2785
|
* @default "cypress/support/{e2e|component}.js"
|
2785
2786
|
*/
|
2786
2787
|
supportFile: string | false
|
2788
|
+
/**
|
2789
|
+
* The test isolation level applied to ensure a clean slate between tests.
|
2790
|
+
* - legacy - resets/clears aliases, intercepts, clock, viewport, cookies, and local storage before each test.
|
2791
|
+
* - strict - applies all resets/clears from legacy, plus clears the page by visiting 'about:blank' to ensure clean app state before each test.
|
2792
|
+
* @default "legacy", however, when experimentalSessionAndOrigin=true, the default is "strict"
|
2793
|
+
*/
|
2794
|
+
testIsolation: 'legacy' | 'strict'
|
2787
2795
|
/**
|
2788
2796
|
* Path to folder where videos will be saved after a headless or CI run
|
2789
2797
|
* @default "cypress/videos"
|
@@ -2859,10 +2867,15 @@ declare namespace Cypress {
|
|
2859
2867
|
*/
|
2860
2868
|
experimentalModifyObstructiveThirdPartyCode: boolean
|
2861
2869
|
/**
|
2862
|
-
*
|
2870
|
+
* Enables AST-based JS/HTML rewriting. This may fix issues caused by the existing regex-based JS/HTML replacement algorithm.
|
2863
2871
|
* @default false
|
2864
2872
|
*/
|
2865
2873
|
experimentalSourceRewriting: boolean
|
2874
|
+
/**
|
2875
|
+
* Generate and save commands directly to your test suite by interacting with your app as an end user would.
|
2876
|
+
* @default false
|
2877
|
+
*/
|
2878
|
+
experimentalStudio: boolean
|
2866
2879
|
/**
|
2867
2880
|
* Number of times to retry a failed test.
|
2868
2881
|
* If a number is set, tests will retry in both runMode and openMode.
|
@@ -3040,21 +3053,39 @@ declare namespace Cypress {
|
|
3040
3053
|
|
3041
3054
|
type PickConfigOpt<T> = T extends keyof DefineDevServerConfig ? DefineDevServerConfig[T] : any
|
3042
3055
|
|
3056
|
+
interface AngularDevServerProjectConfig {
|
3057
|
+
root: string,
|
3058
|
+
sourceRoot: string,
|
3059
|
+
buildOptions: Record<string, any>
|
3060
|
+
}
|
3061
|
+
|
3043
3062
|
type DevServerFn<ComponentDevServerOpts = any> = (cypressDevServerConfig: DevServerConfig, devServerConfig: ComponentDevServerOpts) => ResolvedDevServerConfig | Promise<ResolvedDevServerConfig>
|
3044
3063
|
|
3045
3064
|
type DevServerConfigOptions = {
|
3046
3065
|
bundler: 'webpack'
|
3047
|
-
framework: 'react' | 'vue' | 'vue-cli' | 'nuxt' | 'create-react-app' | 'next'
|
3066
|
+
framework: 'react' | 'vue' | 'vue-cli' | 'nuxt' | 'create-react-app' | 'next' | 'svelte'
|
3048
3067
|
webpackConfig?: PickConfigOpt<'webpackConfig'>
|
3049
3068
|
} | {
|
3050
3069
|
bundler: 'vite'
|
3051
|
-
framework: 'react' | 'vue'
|
3070
|
+
framework: 'react' | 'vue' | 'svelte'
|
3052
3071
|
viteConfig?: Omit<Exclude<PickConfigOpt<'viteConfig'>, undefined>, 'base' | 'root'>
|
3072
|
+
} | {
|
3073
|
+
bundler: 'webpack',
|
3074
|
+
framework: 'angular',
|
3075
|
+
webpackConfig?: PickConfigOpt<'webpackConfig'>,
|
3076
|
+
options?: {
|
3077
|
+
projectConfig: AngularDevServerProjectConfig
|
3078
|
+
}
|
3053
3079
|
}
|
3054
3080
|
|
3055
|
-
interface ComponentConfigOptions<ComponentDevServerOpts = any> extends Omit<CoreConfigOptions, 'baseUrl' | 'experimentalSessionAndOrigin'> {
|
3081
|
+
interface ComponentConfigOptions<ComponentDevServerOpts = any> extends Omit<CoreConfigOptions, 'baseUrl' | 'experimentalSessionAndOrigin' | 'experimentalStudio'> {
|
3056
3082
|
devServer: DevServerFn<ComponentDevServerOpts> | DevServerConfigOptions
|
3057
3083
|
devServerConfig?: ComponentDevServerOpts
|
3084
|
+
/**
|
3085
|
+
* Runs all component specs in a single tab, trading spec isolation for faster run mode execution.
|
3086
|
+
* @default false
|
3087
|
+
*/
|
3088
|
+
experimentalSingleTabRunMode?: boolean
|
3058
3089
|
}
|
3059
3090
|
|
3060
3091
|
/**
|
@@ -3066,7 +3097,12 @@ declare namespace Cypress {
|
|
3066
3097
|
* Takes ComponentDevServerOpts to track the signature of the devServerConfig for the provided `devServer`,
|
3067
3098
|
* so we have proper completion for `devServerConfig`
|
3068
3099
|
*/
|
3069
|
-
type ConfigOptions<ComponentDevServerOpts = any> = Partial<UserConfigOptions<ComponentDevServerOpts>>
|
3100
|
+
type ConfigOptions<ComponentDevServerOpts = any> = Partial<UserConfigOptions<ComponentDevServerOpts>> & {
|
3101
|
+
/**
|
3102
|
+
* Hosts mappings to IP addresses.
|
3103
|
+
*/
|
3104
|
+
hosts?: null | {[key: string]: string}
|
3105
|
+
}
|
3070
3106
|
|
3071
3107
|
interface PluginConfigOptions extends ResolvedConfigOptions, RuntimeConfigOptions {
|
3072
3108
|
/**
|
@@ -5766,6 +5802,26 @@ declare namespace Cypress {
|
|
5766
5802
|
* cy.clock().invoke('restore')
|
5767
5803
|
*/
|
5768
5804
|
restore(): void
|
5805
|
+
/**
|
5806
|
+
* Change the time without invoking any timers.
|
5807
|
+
*
|
5808
|
+
* Default value with no argument or undefined is 0.
|
5809
|
+
*
|
5810
|
+
* This can be useful if you need to change the time by an hour
|
5811
|
+
* while there is a setInterval registered that may otherwise run thousands
|
5812
|
+
* of times.
|
5813
|
+
* @see https://on.cypress.io/clock
|
5814
|
+
* @example
|
5815
|
+
* cy.clock()
|
5816
|
+
* cy.visit('/')
|
5817
|
+
* ...
|
5818
|
+
* cy.clock().then(clock => {
|
5819
|
+
* clock.setSystemTime(60 * 60 * 1000)
|
5820
|
+
* })
|
5821
|
+
* // or use this shortcut
|
5822
|
+
* cy.clock().invoke('setSystemTime', 60 * 60 * 1000)
|
5823
|
+
*/
|
5824
|
+
setSystemTime(now?: number | Date): void
|
5769
5825
|
}
|
5770
5826
|
|
5771
5827
|
interface Cookie {
|
package/vue/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# [@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
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* remove CT side effects from mount when e2e testing ([#22633](https://github.com/cypress-io/cypress/issues/22633)) ([a9476ec](https://github.com/cypress-io/cypress/commit/a9476ecb3d43f628b689e060294a1952937cb1a7))
|
7
|
+
* remove dependency causing semantic-release to fail ([#23142](https://github.com/cypress-io/cypress/issues/23142)) ([20f89bf](https://github.com/cypress-io/cypress/commit/20f89bfa32636baa8922896e719962c703129abd))
|
8
|
+
|
9
|
+
|
10
|
+
### Features
|
11
|
+
|
12
|
+
* **npm/vue:** expose Test Utils API ([#22757](https://github.com/cypress-io/cypress/issues/22757)) ([8e07318](https://github.com/cypress-io/cypress/commit/8e07318a9f72c3df012be47d500007571165a87e))
|
13
|
+
* update to Vite 3 ([#22915](https://github.com/cypress-io/cypress/issues/22915)) ([6adba46](https://github.com/cypress-io/cypress/commit/6adba462ea6b76dbb96f99aa3837492ca1f17ed3))
|
14
|
+
|
1
15
|
# [@cypress/vue-v4.0.0](https://github.com/cypress-io/cypress/compare/@cypress/vue-v3.1.2...@cypress/vue-v4.0.0) (2022-06-13)
|
2
16
|
|
3
17
|
|