cypress 13.3.0 โ 13.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/angular/angular/README.md +10 -0
- package/angular/angular/dist/index.d.ts +128 -0
- package/angular/angular/dist/index.js +333 -0
- package/angular/angular/package.json +77 -0
- package/angular/package.json +9 -1
- package/lib/exec/spawn.js +1 -1
- package/lib/util.js +1 -1
- package/mount-utils/mount-utils/README.md +140 -0
- package/mount-utils/mount-utils/dist/index.d.ts +40 -0
- package/mount-utils/mount-utils/dist/index.js +68 -0
- package/mount-utils/mount-utils/package.json +46 -0
- package/mount-utils/package.json +10 -1
- package/package.json +20 -4
- package/react/package.json +13 -0
- package/react/react/README.md +14 -0
- package/react/react/dist/cypress-react.cjs.js +943 -0
- package/react/react/dist/cypress-react.esm-bundler.js +917 -0
- package/react/react/dist/index.d.ts +111 -0
- package/react/react/package.json +111 -0
- package/react18/package.json +10 -0
- package/react18/react18/README.md +7 -0
- package/react18/react18/dist/cypress-react.cjs.js +592 -0
- package/react18/react18/dist/cypress-react.esm-bundler.js +569 -0
- package/react18/react18/dist/index.d.ts +78 -0
- package/react18/react18/package.json +71 -0
- package/svelte/package.json +13 -1
- package/svelte/svelte/README.md +15 -0
- package/svelte/svelte/dist/cypress-svelte.cjs.js +122 -0
- package/svelte/svelte/dist/cypress-svelte.esm-bundler.js +120 -0
- package/svelte/svelte/dist/index.d.ts +201 -0
- package/svelte/svelte/package.json +56 -0
- package/types/cypress.d.ts +2 -2
- package/vue/package.json +13 -1
- package/vue/vue/README.md +14 -0
- package/vue/vue/dist/cypress-vue.cjs.js +8582 -0
- package/vue/vue/dist/cypress-vue.esm-bundler.js +8560 -0
- package/vue/vue/dist/index.d.ts +1392 -0
- package/vue/vue/package.json +96 -0
- package/vue2/dist/cypress-vue2.cjs.js +1 -1
- package/vue2/dist/cypress-vue2.esm-bundler.js +1 -1
- package/vue2/package.json +13 -1
- package/vue2/vue2/README.md +7 -0
- package/vue2/vue2/dist/cypress-vue2.cjs.js +20045 -0
- package/vue2/vue2/dist/cypress-vue2.esm-bundler.js +20042 -0
- package/vue2/vue2/dist/index.d.ts +364 -0
- package/vue2/vue2/package.json +65 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
{
|
2
|
+
"name": "@cypress/react18",
|
3
|
+
"version": "0.0.0-development",
|
4
|
+
"description": "Test React components using Cypress",
|
5
|
+
"main": "dist/cypress-react.cjs.js",
|
6
|
+
"scripts": {
|
7
|
+
"build": "rimraf dist && rollup -c rollup.config.mjs",
|
8
|
+
"postbuild": "node ../../scripts/sync-exported-npm-with-cli.js",
|
9
|
+
"check-ts": "tsc --noEmit",
|
10
|
+
"watch": "yarn build --watch --watch.exclude ./dist/**/*",
|
11
|
+
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, ."
|
12
|
+
},
|
13
|
+
"devDependencies": {
|
14
|
+
"@cypress/mount-utils": "0.0.0-development",
|
15
|
+
"@cypress/react": "0.0.0-development",
|
16
|
+
"@rollup/plugin-commonjs": "^17.1.0",
|
17
|
+
"@rollup/plugin-node-resolve": "^11.1.1",
|
18
|
+
"@types/react": "^16",
|
19
|
+
"@types/react-dom": "^16",
|
20
|
+
"cypress": "0.0.0-development",
|
21
|
+
"react": "^16",
|
22
|
+
"react-dom": "^16",
|
23
|
+
"rollup": "3.7.3",
|
24
|
+
"rollup-plugin-typescript2": "^0.29.0",
|
25
|
+
"typescript": "^4.7.4"
|
26
|
+
},
|
27
|
+
"peerDependencies": {
|
28
|
+
"@types/react": "^18",
|
29
|
+
"@types/react-dom": "^18",
|
30
|
+
"cypress": "*",
|
31
|
+
"react": "^18",
|
32
|
+
"react-dom": "^18"
|
33
|
+
},
|
34
|
+
"files": [
|
35
|
+
"dist"
|
36
|
+
],
|
37
|
+
"types": "dist/index.d.ts",
|
38
|
+
"license": "MIT",
|
39
|
+
"repository": {
|
40
|
+
"type": "git",
|
41
|
+
"url": "https://github.com/cypress-io/cypress.git"
|
42
|
+
},
|
43
|
+
"homepage": "https://github.com/cypress-io/cypress/blob/develop/npm/react18/#readme",
|
44
|
+
"bugs": "https://github.com/cypress-io/cypress/issues/new?assignees=&labels=npm%3A%20%40cypress%2Freact18&template=1-bug-report.md&title=",
|
45
|
+
"keywords": [
|
46
|
+
"react",
|
47
|
+
"cypress",
|
48
|
+
"cypress-io",
|
49
|
+
"test",
|
50
|
+
"testing"
|
51
|
+
],
|
52
|
+
"module": "dist/cypress-react.esm-bundler.js",
|
53
|
+
"peerDependenciesMeta": {
|
54
|
+
"@types/react": {
|
55
|
+
"optional": true
|
56
|
+
}
|
57
|
+
},
|
58
|
+
"publishConfig": {
|
59
|
+
"access": "public"
|
60
|
+
},
|
61
|
+
"nx": {
|
62
|
+
"targets": {
|
63
|
+
"build": {
|
64
|
+
"outputs": [
|
65
|
+
"{workspaceRoot}/cli/react18",
|
66
|
+
"{projectRoot}/dist"
|
67
|
+
]
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
package/svelte/package.json
CHANGED
@@ -7,7 +7,6 @@
|
|
7
7
|
"prebuild": "rimraf dist",
|
8
8
|
"build": "rollup -c rollup.config.mjs",
|
9
9
|
"postbuild": "node ../../scripts/sync-exported-npm-with-cli.js",
|
10
|
-
"build-prod": "yarn build",
|
11
10
|
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .",
|
12
11
|
"check-ts": "tsc --noEmit"
|
13
12
|
},
|
@@ -40,5 +39,18 @@
|
|
40
39
|
"module": "dist/cypress-svelte.esm-bundler.js",
|
41
40
|
"publishConfig": {
|
42
41
|
"access": "public"
|
42
|
+
},
|
43
|
+
"nx": {
|
44
|
+
"targets": {
|
45
|
+
"build": {
|
46
|
+
"outputs": [
|
47
|
+
"{workspaceRoot}/cli/svelte",
|
48
|
+
"{projectRoot}/dist"
|
49
|
+
]
|
50
|
+
}
|
51
|
+
},
|
52
|
+
"implicitDependencies": [
|
53
|
+
"!cypress"
|
54
|
+
]
|
43
55
|
}
|
44
56
|
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# @cypress/svelte
|
2
|
+
|
3
|
+
Mount Svelte components in the open source [Cypress.io](https://www.cypress.io/) test runner **v10.7.0+**
|
4
|
+
|
5
|
+
> **Note:** This package is bundled with the `cypress` package and should not need to be installed separately. See the [Svelte Component Testing Docs](https://docs.cypress.io/guides/component-testing/svelte/overview) for mounting Svelte components. Installing and importing `mount` from `@cypress/svelte` should only be done for advanced use-cases.
|
6
|
+
|
7
|
+
## Development
|
8
|
+
|
9
|
+
Run `yarn build` to compile and sync packages to the `cypress` cli package.
|
10
|
+
|
11
|
+
Run `yarn cy:open` to open Cypress component testing against real-world examples.
|
12
|
+
|
13
|
+
Run `yarn test` to execute headless Cypress tests.
|
14
|
+
|
15
|
+
## [Changelog](./CHANGELOG.md)
|
@@ -0,0 +1,122 @@
|
|
1
|
+
|
2
|
+
/**
|
3
|
+
* @cypress/svelte v0.0.0-development
|
4
|
+
* (c) 2023 Cypress.io
|
5
|
+
* Released under the MIT License
|
6
|
+
*/
|
7
|
+
|
8
|
+
'use strict';
|
9
|
+
|
10
|
+
const ROOT_SELECTOR = '[data-cy-root]';
|
11
|
+
/**
|
12
|
+
* Gets the root element used to mount the component.
|
13
|
+
* @returns {HTMLElement} The root element
|
14
|
+
* @throws {Error} If the root element is not found
|
15
|
+
*/
|
16
|
+
const getContainerEl = () => {
|
17
|
+
const el = document.querySelector(ROOT_SELECTOR);
|
18
|
+
if (el) {
|
19
|
+
return el;
|
20
|
+
}
|
21
|
+
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.`);
|
22
|
+
};
|
23
|
+
function checkForRemovedStyleOptions(mountingOptions) {
|
24
|
+
for (const key of ['cssFile', 'cssFiles', 'style', 'styles', 'stylesheet', 'stylesheets']) {
|
25
|
+
if (mountingOptions[key]) {
|
26
|
+
Cypress.utils.throwErrByPath('mount.removed_style_mounting_options', key);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
/**
|
31
|
+
* Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook
|
32
|
+
* @param optionalCallback Callback to be called before the next test runs
|
33
|
+
*/
|
34
|
+
function setupHooks(optionalCallback) {
|
35
|
+
// We don't want CT side effects to run when e2e
|
36
|
+
// testing so we early return.
|
37
|
+
// System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
|
38
|
+
if (Cypress.testingType !== 'component') {
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
// When running component specs, we cannot allow "cy.visit"
|
42
|
+
// because it will wipe out our preparation work, and does not make much sense
|
43
|
+
// thus we overwrite "cy.visit" to throw an error
|
44
|
+
Cypress.Commands.overwrite('visit', () => {
|
45
|
+
throw new Error('cy.visit from a component spec is not allowed');
|
46
|
+
});
|
47
|
+
Cypress.Commands.overwrite('session', () => {
|
48
|
+
throw new Error('cy.session from a component spec is not allowed');
|
49
|
+
});
|
50
|
+
Cypress.Commands.overwrite('origin', () => {
|
51
|
+
throw new Error('cy.origin from a component spec is not allowed');
|
52
|
+
});
|
53
|
+
// @ts-ignore
|
54
|
+
Cypress.on('test:before:after:run:async', () => {
|
55
|
+
optionalCallback === null || optionalCallback === void 0 ? void 0 : optionalCallback();
|
56
|
+
});
|
57
|
+
}
|
58
|
+
|
59
|
+
const DEFAULT_COMP_NAME = 'unknown';
|
60
|
+
let componentInstance;
|
61
|
+
const cleanup = () => {
|
62
|
+
componentInstance === null || componentInstance === void 0 ? void 0 : componentInstance.$destroy();
|
63
|
+
};
|
64
|
+
// Extract the component name from the object passed to mount
|
65
|
+
const getComponentDisplayName = (Component) => {
|
66
|
+
if (Component.name) {
|
67
|
+
const [, match] = /Proxy\<(\w+)\>/.exec(Component.name) || [];
|
68
|
+
return match || Component.name;
|
69
|
+
}
|
70
|
+
return DEFAULT_COMP_NAME;
|
71
|
+
};
|
72
|
+
/**
|
73
|
+
* Mounts a Svelte component inside the Cypress browser
|
74
|
+
*
|
75
|
+
* @param {SvelteConstructor<T>} Component Svelte component being mounted
|
76
|
+
* @param {MountReturn<T extends SvelteComponent>} options options to customize the component being mounted
|
77
|
+
* @returns Cypress.Chainable<MountReturn>
|
78
|
+
*
|
79
|
+
* @example
|
80
|
+
* import Counter from './Counter.svelte'
|
81
|
+
* import { mount } from 'cypress/svelte'
|
82
|
+
*
|
83
|
+
* it('should render', () => {
|
84
|
+
* mount(Counter, { props: { count: 42 } })
|
85
|
+
* cy.get('button').contains(42)
|
86
|
+
* })
|
87
|
+
*
|
88
|
+
* @see {@link https://on.cypress.io/mounting-svelte} for more details.
|
89
|
+
*/
|
90
|
+
function mount(Component, options = {}) {
|
91
|
+
checkForRemovedStyleOptions(options);
|
92
|
+
return cy.then(() => {
|
93
|
+
// Remove last mounted component if cy.mount is called more than once in a test
|
94
|
+
cleanup();
|
95
|
+
const target = getContainerEl();
|
96
|
+
const ComponentConstructor = (Component.default || Component);
|
97
|
+
componentInstance = new ComponentConstructor(Object.assign({ target }, options));
|
98
|
+
// by waiting, we are delaying test execution for the next tick of event loop
|
99
|
+
// and letting hooks and component lifecycle methods to execute mount
|
100
|
+
return cy.wait(0, { log: false }).then(() => {
|
101
|
+
if (options.log !== false) {
|
102
|
+
const mountMessage = `<${getComponentDisplayName(Component)} ... />`;
|
103
|
+
Cypress.log({
|
104
|
+
name: 'mount',
|
105
|
+
message: [mountMessage],
|
106
|
+
});
|
107
|
+
}
|
108
|
+
})
|
109
|
+
.wrap({ component: componentInstance }, { log: false });
|
110
|
+
});
|
111
|
+
}
|
112
|
+
// Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
|
113
|
+
// by creating an explicit function/import that the user can register in their 'component.js' support file,
|
114
|
+
// such as:
|
115
|
+
// import 'cypress/<my-framework>/support'
|
116
|
+
// or
|
117
|
+
// import { registerCT } from 'cypress/<my-framework>'
|
118
|
+
// registerCT()
|
119
|
+
// Note: This would be a breaking change
|
120
|
+
setupHooks(cleanup);
|
121
|
+
|
122
|
+
exports.mount = mount;
|
@@ -0,0 +1,120 @@
|
|
1
|
+
|
2
|
+
/**
|
3
|
+
* @cypress/svelte v0.0.0-development
|
4
|
+
* (c) 2023 Cypress.io
|
5
|
+
* Released under the MIT License
|
6
|
+
*/
|
7
|
+
|
8
|
+
const ROOT_SELECTOR = '[data-cy-root]';
|
9
|
+
/**
|
10
|
+
* Gets the root element used to mount the component.
|
11
|
+
* @returns {HTMLElement} The root element
|
12
|
+
* @throws {Error} If the root element is not found
|
13
|
+
*/
|
14
|
+
const getContainerEl = () => {
|
15
|
+
const el = document.querySelector(ROOT_SELECTOR);
|
16
|
+
if (el) {
|
17
|
+
return el;
|
18
|
+
}
|
19
|
+
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.`);
|
20
|
+
};
|
21
|
+
function checkForRemovedStyleOptions(mountingOptions) {
|
22
|
+
for (const key of ['cssFile', 'cssFiles', 'style', 'styles', 'stylesheet', 'stylesheets']) {
|
23
|
+
if (mountingOptions[key]) {
|
24
|
+
Cypress.utils.throwErrByPath('mount.removed_style_mounting_options', key);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
/**
|
29
|
+
* Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook
|
30
|
+
* @param optionalCallback Callback to be called before the next test runs
|
31
|
+
*/
|
32
|
+
function setupHooks(optionalCallback) {
|
33
|
+
// We don't want CT side effects to run when e2e
|
34
|
+
// testing so we early return.
|
35
|
+
// System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
|
36
|
+
if (Cypress.testingType !== 'component') {
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
// When running component specs, we cannot allow "cy.visit"
|
40
|
+
// because it will wipe out our preparation work, and does not make much sense
|
41
|
+
// thus we overwrite "cy.visit" to throw an error
|
42
|
+
Cypress.Commands.overwrite('visit', () => {
|
43
|
+
throw new Error('cy.visit from a component spec is not allowed');
|
44
|
+
});
|
45
|
+
Cypress.Commands.overwrite('session', () => {
|
46
|
+
throw new Error('cy.session from a component spec is not allowed');
|
47
|
+
});
|
48
|
+
Cypress.Commands.overwrite('origin', () => {
|
49
|
+
throw new Error('cy.origin from a component spec is not allowed');
|
50
|
+
});
|
51
|
+
// @ts-ignore
|
52
|
+
Cypress.on('test:before:after:run:async', () => {
|
53
|
+
optionalCallback === null || optionalCallback === void 0 ? void 0 : optionalCallback();
|
54
|
+
});
|
55
|
+
}
|
56
|
+
|
57
|
+
const DEFAULT_COMP_NAME = 'unknown';
|
58
|
+
let componentInstance;
|
59
|
+
const cleanup = () => {
|
60
|
+
componentInstance === null || componentInstance === void 0 ? void 0 : componentInstance.$destroy();
|
61
|
+
};
|
62
|
+
// Extract the component name from the object passed to mount
|
63
|
+
const getComponentDisplayName = (Component) => {
|
64
|
+
if (Component.name) {
|
65
|
+
const [, match] = /Proxy\<(\w+)\>/.exec(Component.name) || [];
|
66
|
+
return match || Component.name;
|
67
|
+
}
|
68
|
+
return DEFAULT_COMP_NAME;
|
69
|
+
};
|
70
|
+
/**
|
71
|
+
* Mounts a Svelte component inside the Cypress browser
|
72
|
+
*
|
73
|
+
* @param {SvelteConstructor<T>} Component Svelte component being mounted
|
74
|
+
* @param {MountReturn<T extends SvelteComponent>} options options to customize the component being mounted
|
75
|
+
* @returns Cypress.Chainable<MountReturn>
|
76
|
+
*
|
77
|
+
* @example
|
78
|
+
* import Counter from './Counter.svelte'
|
79
|
+
* import { mount } from 'cypress/svelte'
|
80
|
+
*
|
81
|
+
* it('should render', () => {
|
82
|
+
* mount(Counter, { props: { count: 42 } })
|
83
|
+
* cy.get('button').contains(42)
|
84
|
+
* })
|
85
|
+
*
|
86
|
+
* @see {@link https://on.cypress.io/mounting-svelte} for more details.
|
87
|
+
*/
|
88
|
+
function mount(Component, options = {}) {
|
89
|
+
checkForRemovedStyleOptions(options);
|
90
|
+
return cy.then(() => {
|
91
|
+
// Remove last mounted component if cy.mount is called more than once in a test
|
92
|
+
cleanup();
|
93
|
+
const target = getContainerEl();
|
94
|
+
const ComponentConstructor = (Component.default || Component);
|
95
|
+
componentInstance = new ComponentConstructor(Object.assign({ target }, options));
|
96
|
+
// by waiting, we are delaying test execution for the next tick of event loop
|
97
|
+
// and letting hooks and component lifecycle methods to execute mount
|
98
|
+
return cy.wait(0, { log: false }).then(() => {
|
99
|
+
if (options.log !== false) {
|
100
|
+
const mountMessage = `<${getComponentDisplayName(Component)} ... />`;
|
101
|
+
Cypress.log({
|
102
|
+
name: 'mount',
|
103
|
+
message: [mountMessage],
|
104
|
+
});
|
105
|
+
}
|
106
|
+
})
|
107
|
+
.wrap({ component: componentInstance }, { log: false });
|
108
|
+
});
|
109
|
+
}
|
110
|
+
// Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
|
111
|
+
// by creating an explicit function/import that the user can register in their 'component.js' support file,
|
112
|
+
// such as:
|
113
|
+
// import 'cypress/<my-framework>/support'
|
114
|
+
// or
|
115
|
+
// import { registerCT } from 'cypress/<my-framework>'
|
116
|
+
// registerCT()
|
117
|
+
// Note: This would be a breaking change
|
118
|
+
setupHooks(cleanup);
|
119
|
+
|
120
|
+
export { mount };
|
@@ -0,0 +1,201 @@
|
|
1
|
+
/// <reference types="cypress" />
|
2
|
+
|
3
|
+
declare module '*.svelte' {
|
4
|
+
export { SvelteComponentDev as default } from 'svelte/internal';
|
5
|
+
}
|
6
|
+
|
7
|
+
/**
|
8
|
+
* INTERNAL, DO NOT USE. Code may change at any time.
|
9
|
+
*/
|
10
|
+
interface Fragment {
|
11
|
+
key: string | null;
|
12
|
+
first: null;
|
13
|
+
c: () => void;
|
14
|
+
l: (nodes: any) => void;
|
15
|
+
h: () => void;
|
16
|
+
m: (target: HTMLElement, anchor: any) => void;
|
17
|
+
p: (ctx: any, dirty: any) => void;
|
18
|
+
r: () => void;
|
19
|
+
f: () => void;
|
20
|
+
a: () => void;
|
21
|
+
i: (local: any) => void;
|
22
|
+
o: (local: any) => void;
|
23
|
+
d: (detaching: 0 | 1) => void;
|
24
|
+
}
|
25
|
+
interface T$$ {
|
26
|
+
dirty: number[];
|
27
|
+
ctx: null | any;
|
28
|
+
bound: any;
|
29
|
+
update: () => void;
|
30
|
+
callbacks: any;
|
31
|
+
after_update: any[];
|
32
|
+
props: Record<string, 0 | string>;
|
33
|
+
fragment: null | false | Fragment;
|
34
|
+
not_equal: any;
|
35
|
+
before_update: any[];
|
36
|
+
context: Map<any, any>;
|
37
|
+
on_mount: any[];
|
38
|
+
on_destroy: any[];
|
39
|
+
skip_bound: boolean;
|
40
|
+
on_disconnect: any[];
|
41
|
+
root: Element | ShadowRoot;
|
42
|
+
}
|
43
|
+
/**
|
44
|
+
* Base class for Svelte components. Used when dev=false.
|
45
|
+
*/
|
46
|
+
declare class SvelteComponent {
|
47
|
+
$$: T$$;
|
48
|
+
$$set?: ($$props: any) => void;
|
49
|
+
$destroy(): void;
|
50
|
+
$on(type: any, callback: any): () => void;
|
51
|
+
$set($$props: any): void;
|
52
|
+
}
|
53
|
+
|
54
|
+
declare type Props = Record<string, any>;
|
55
|
+
interface ComponentConstructorOptions<Props extends Record<string, any> = Record<string, any>> {
|
56
|
+
target: Element | ShadowRoot;
|
57
|
+
anchor?: Element;
|
58
|
+
props?: Props;
|
59
|
+
context?: Map<any, any>;
|
60
|
+
hydrate?: boolean;
|
61
|
+
intro?: boolean;
|
62
|
+
$$inline?: boolean;
|
63
|
+
}
|
64
|
+
interface SvelteComponentDev$1 {
|
65
|
+
$set(props?: Props): void;
|
66
|
+
$on(event: string, callback: (event: any) => void): () => void;
|
67
|
+
$destroy(): void;
|
68
|
+
[accessor: string]: any;
|
69
|
+
}
|
70
|
+
/**
|
71
|
+
* Base class for Svelte components with some minor dev-enhancements. Used when dev=true.
|
72
|
+
*/
|
73
|
+
declare class SvelteComponentDev$1 extends SvelteComponent {
|
74
|
+
/**
|
75
|
+
* @private
|
76
|
+
* For type checking capabilities only.
|
77
|
+
* Does not exist at runtime.
|
78
|
+
* ### DO NOT USE!
|
79
|
+
*/
|
80
|
+
$$prop_def: Props;
|
81
|
+
/**
|
82
|
+
* @private
|
83
|
+
* For type checking capabilities only.
|
84
|
+
* Does not exist at runtime.
|
85
|
+
* ### DO NOT USE!
|
86
|
+
*/
|
87
|
+
$$events_def: any;
|
88
|
+
/**
|
89
|
+
* @private
|
90
|
+
* For type checking capabilities only.
|
91
|
+
* Does not exist at runtime.
|
92
|
+
* ### DO NOT USE!
|
93
|
+
*/
|
94
|
+
$$slot_def: any;
|
95
|
+
constructor(options: ComponentConstructorOptions);
|
96
|
+
$capture_state(): void;
|
97
|
+
$inject_state(): void;
|
98
|
+
}
|
99
|
+
interface SvelteComponentTyped<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any> {
|
100
|
+
$set(props?: Partial<Props>): void;
|
101
|
+
$on<K extends Extract<keyof Events, string>>(type: K, callback: (e: Events[K]) => void): () => void;
|
102
|
+
$destroy(): void;
|
103
|
+
[accessor: string]: any;
|
104
|
+
}
|
105
|
+
/**
|
106
|
+
* Base class to create strongly typed Svelte components.
|
107
|
+
* This only exists for typing purposes and should be used in `.d.ts` files.
|
108
|
+
*
|
109
|
+
* ### Example:
|
110
|
+
*
|
111
|
+
* You have component library on npm called `component-library`, from which
|
112
|
+
* you export a component called `MyComponent`. For Svelte+TypeScript users,
|
113
|
+
* you want to provide typings. Therefore you create a `index.d.ts`:
|
114
|
+
* ```ts
|
115
|
+
* import { SvelteComponentTyped } from "svelte";
|
116
|
+
* export class MyComponent extends SvelteComponentTyped<{foo: string}> {}
|
117
|
+
* ```
|
118
|
+
* Typing this makes it possible for IDEs like VS Code with the Svelte extension
|
119
|
+
* to provide intellisense and to use the component like this in a Svelte file
|
120
|
+
* with TypeScript:
|
121
|
+
* ```svelte
|
122
|
+
* <script lang="ts">
|
123
|
+
* import { MyComponent } from "component-library";
|
124
|
+
* </script>
|
125
|
+
* <MyComponent foo={'bar'} />
|
126
|
+
* ```
|
127
|
+
*
|
128
|
+
* #### Why not make this part of `SvelteComponent(Dev)`?
|
129
|
+
* Because
|
130
|
+
* ```ts
|
131
|
+
* class ASubclassOfSvelteComponent extends SvelteComponent<{foo: string}> {}
|
132
|
+
* const component: typeof SvelteComponent = ASubclassOfSvelteComponent;
|
133
|
+
* ```
|
134
|
+
* will throw a type error, so we need to separate the more strictly typed class.
|
135
|
+
*/
|
136
|
+
declare class SvelteComponentTyped<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any> extends SvelteComponentDev$1 {
|
137
|
+
/**
|
138
|
+
* @private
|
139
|
+
* For type checking capabilities only.
|
140
|
+
* Does not exist at runtime.
|
141
|
+
* ### DO NOT USE!
|
142
|
+
*/
|
143
|
+
$$prop_def: Props;
|
144
|
+
/**
|
145
|
+
* @private
|
146
|
+
* For type checking capabilities only.
|
147
|
+
* Does not exist at runtime.
|
148
|
+
* ### DO NOT USE!
|
149
|
+
*/
|
150
|
+
$$events_def: Events;
|
151
|
+
/**
|
152
|
+
* @private
|
153
|
+
* For type checking capabilities only.
|
154
|
+
* Does not exist at runtime.
|
155
|
+
* ### DO NOT USE!
|
156
|
+
*/
|
157
|
+
$$slot_def: Slots;
|
158
|
+
constructor(options: ComponentConstructorOptions<Props>);
|
159
|
+
}
|
160
|
+
/**
|
161
|
+
* Convenience type to get the props the given component expects. Example:
|
162
|
+
* ```html
|
163
|
+
* <script lang="ts">
|
164
|
+
* import type { ComponentProps } from 'svelte';
|
165
|
+
* import Component from './Component.svelte';
|
166
|
+
*
|
167
|
+
* const props: ComponentProps<Component> = { foo: 'bar' }; // Errors if these aren't the correct props
|
168
|
+
* </script>
|
169
|
+
* ```
|
170
|
+
*/
|
171
|
+
declare type ComponentProps<Component extends SvelteComponent> = Component extends SvelteComponentTyped<infer Props> ? Props : never;
|
172
|
+
|
173
|
+
declare type SvelteConstructor<T> = new (...args: any[]) => T;
|
174
|
+
declare type SvelteComponentOptions<T extends SvelteComponentDev$1> = Omit<ComponentConstructorOptions<ComponentProps<T>>, 'hydrate' | 'target' | '$$inline'>;
|
175
|
+
interface MountOptions<T extends SvelteComponentDev$1> extends SvelteComponentOptions<T> {
|
176
|
+
log?: boolean;
|
177
|
+
}
|
178
|
+
interface MountReturn<T extends SvelteComponentDev$1> {
|
179
|
+
component: T;
|
180
|
+
}
|
181
|
+
/**
|
182
|
+
* Mounts a Svelte component inside the Cypress browser
|
183
|
+
*
|
184
|
+
* @param {SvelteConstructor<T>} Component Svelte component being mounted
|
185
|
+
* @param {MountReturn<T extends SvelteComponent>} options options to customize the component being mounted
|
186
|
+
* @returns Cypress.Chainable<MountReturn>
|
187
|
+
*
|
188
|
+
* @example
|
189
|
+
* import Counter from './Counter.svelte'
|
190
|
+
* import { mount } from 'cypress/svelte'
|
191
|
+
*
|
192
|
+
* it('should render', () => {
|
193
|
+
* mount(Counter, { props: { count: 42 } })
|
194
|
+
* cy.get('button').contains(42)
|
195
|
+
* })
|
196
|
+
*
|
197
|
+
* @see {@link https://on.cypress.io/mounting-svelte} for more details.
|
198
|
+
*/
|
199
|
+
declare function mount<T extends SvelteComponentDev$1>(Component: SvelteConstructor<T>, options?: MountOptions<T>): Cypress.Chainable<MountReturn<T>>;
|
200
|
+
|
201
|
+
export { MountOptions, MountReturn, mount };
|
@@ -0,0 +1,56 @@
|
|
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
|
+
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .",
|
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/develop/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
|
+
"nx": {
|
44
|
+
"targets": {
|
45
|
+
"build": {
|
46
|
+
"outputs": [
|
47
|
+
"{workspaceRoot}/cli/svelte",
|
48
|
+
"{projectRoot}/dist"
|
49
|
+
]
|
50
|
+
}
|
51
|
+
},
|
52
|
+
"implicitDependencies": [
|
53
|
+
"!cypress"
|
54
|
+
]
|
55
|
+
}
|
56
|
+
}
|
package/types/cypress.d.ts
CHANGED
@@ -3318,7 +3318,7 @@ declare namespace Cypress {
|
|
3318
3318
|
|
3319
3319
|
interface CypressComponentDependency {
|
3320
3320
|
/**
|
3321
|
-
* Unique
|
3321
|
+
* Unique identifier.
|
3322
3322
|
* @example 'reactscripts'
|
3323
3323
|
*/
|
3324
3324
|
type: string
|
@@ -3453,7 +3453,7 @@ declare namespace Cypress {
|
|
3453
3453
|
componentIndexHtml?: () => string
|
3454
3454
|
|
3455
3455
|
/**
|
3456
|
-
* Used for the Create From
|
3456
|
+
* Used for the Create From Component feature.
|
3457
3457
|
* This is currently not supported for third party frameworks.
|
3458
3458
|
*/
|
3459
3459
|
specPattern?: '**/*.cy.ts'
|
package/vue/package.json
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
"description": "Browser-based Component Testing for Vue.js with Cypress.io โ๏ธ๐ฒ",
|
5
5
|
"main": "dist/cypress-vue.cjs.js",
|
6
6
|
"scripts": {
|
7
|
-
"build-prod": "yarn build",
|
8
7
|
"cy:open": "node ../../scripts/cypress.js open --component --project ${PWD}",
|
9
8
|
"cy:run": "node ../../scripts/cypress.js run --component --project ${PWD}",
|
10
9
|
"build": "rimraf dist && rollup -c rollup.config.mjs",
|
@@ -80,5 +79,18 @@
|
|
80
79
|
},
|
81
80
|
"publishConfig": {
|
82
81
|
"access": "public"
|
82
|
+
},
|
83
|
+
"nx": {
|
84
|
+
"targets": {
|
85
|
+
"build": {
|
86
|
+
"dependsOn": [
|
87
|
+
"!@cypress/react18:build"
|
88
|
+
],
|
89
|
+
"outputs": [
|
90
|
+
"{workspaceRoot}/cli/vue",
|
91
|
+
"{projectRoot}/dist"
|
92
|
+
]
|
93
|
+
}
|
94
|
+
}
|
83
95
|
}
|
84
96
|
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# @cypress/vue
|
2
|
+
|
3
|
+
Mount Vue 3 components in the open source [Cypress.io](https://www.cypress.io/) test runner
|
4
|
+
|
5
|
+
> **Note:** This package is bundled with the `cypress` package and should not need to be installed separately. See the [Vue Component Testing Docs](https://docs.cypress.io/guides/component-testing/vue/overview) for mounting Vue components. Installing and importing `mount` from `@cypress/vue` should only be done for advanced use-cases.
|
6
|
+
## Development
|
7
|
+
|
8
|
+
Run `yarn build` to compile and sync packages to the `cypress` cli package.
|
9
|
+
|
10
|
+
Run `yarn cy:open` to open Cypress component testing against real-world examples.
|
11
|
+
|
12
|
+
Run `yarn test` to execute headless Cypress tests.
|
13
|
+
|
14
|
+
## [Changelog](./CHANGELOG.md)
|