@forsakringskassan/cypress-config 1.8.0 → 1.9.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/README.md +12 -2
- package/dist/support.d.ts +42 -2
- package/dist/support.mjs +30 -25
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ A configuration function is available for usage in `cypress/support/e2e.ts` and/
|
|
|
54
54
|
```ts
|
|
55
55
|
import { configure } from "@forsakringskassan/cypress-config/support";
|
|
56
56
|
|
|
57
|
-
configure({
|
|
57
|
+
await configure({
|
|
58
58
|
resetEmulatedMedia: true,
|
|
59
59
|
afterEach: {
|
|
60
60
|
htmlvalidate: true,
|
|
@@ -97,6 +97,16 @@ Cypress.Commands.add("mount", (component, options = {}) => {
|
|
|
97
97
|
});
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
+
For advanced usage, use the `createMount()` call to create the `mount()` function manually:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { createMount } from "@forsakringskassan/cypress-config/support";
|
|
104
|
+
|
|
105
|
+
const mount = await createMount({/* options */});
|
|
106
|
+
|
|
107
|
+
Cypress.Commands.add("mount", mount);
|
|
108
|
+
```
|
|
109
|
+
|
|
100
110
|
### Commands
|
|
101
111
|
|
|
102
112
|
This preset adds new custom commands:
|
|
@@ -209,7 +219,7 @@ To automatically run validation after each test configure it using the configura
|
|
|
209
219
|
```ts
|
|
210
220
|
import { configure } from "@forsakringskassan/cypress-config/support";
|
|
211
221
|
|
|
212
|
-
configure({
|
|
222
|
+
await configure({
|
|
213
223
|
resetEmulatedMedia: true,
|
|
214
224
|
afterEach: {
|
|
215
225
|
htmlvalidate: true,
|
package/dist/support.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type * as FkuiVue from '@fkui/vue';
|
|
1
2
|
import { mount as mount_2 } from 'cypress/vue';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -7,20 +8,59 @@ import { mount as mount_2 } from 'cypress/vue';
|
|
|
7
8
|
* @since v1.1.0
|
|
8
9
|
*/
|
|
9
10
|
export declare function configure(options: {
|
|
11
|
+
fkuiVue?: typeof FkuiVue;
|
|
10
12
|
/** When enabled, any emulated CSS media features will be reset between runs */
|
|
11
13
|
resetEmulatedMedia: boolean;
|
|
12
14
|
afterEach: {
|
|
13
15
|
htmlvalidate: boolean;
|
|
14
16
|
};
|
|
15
|
-
}): void
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a wrapper around `mount()` from `cypress/vue` with new defaults.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { createMount } from "@forsakringskassan/cypress-config/support";
|
|
26
|
+
*
|
|
27
|
+
* const mount = await createMount();
|
|
28
|
+
*
|
|
29
|
+
* Cypress.Commands.add("mount", mount);
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @remarks When passing in a custom `fkuiVue` module a default static copy will
|
|
33
|
+
* still be imported (but largely unused), this is due to how Cypress bundles
|
|
34
|
+
* the files (including dynamic imports). Any global side-effects will run for
|
|
35
|
+
* both!
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
* @since v1.9.0
|
|
39
|
+
*/
|
|
40
|
+
export declare function createMount(options?: {
|
|
41
|
+
fkuiVue?: typeof FkuiVue;
|
|
42
|
+
}): Promise<MountFn>;
|
|
16
43
|
|
|
17
44
|
/**
|
|
18
45
|
* Wrapper around `mount()` from `cypress/vue` with new defaults.
|
|
19
46
|
*
|
|
47
|
+
* If you need to customize the `mount()` behaviour use `createMount()`.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { mount } from "@forsakringskassan/cypress-config/support";
|
|
53
|
+
*
|
|
54
|
+
* Cypress.Commands.add("mount", mount);
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
20
57
|
* @public
|
|
21
58
|
* @since v1.7.0
|
|
22
59
|
*/
|
|
23
|
-
export declare const mount:
|
|
60
|
+
export declare const mount: MountFn;
|
|
61
|
+
|
|
62
|
+
/** @public */
|
|
63
|
+
export declare type MountFn = (component: Parameters<typeof mount_2>[0], options?: NonNullable<Parameters<typeof mount_2>[1]>) => ReturnType<typeof mount_2>;
|
|
24
64
|
|
|
25
65
|
export { }
|
|
26
66
|
|
package/dist/support.mjs
CHANGED
|
@@ -68,7 +68,6 @@ Cypress.Commands.add("prefersColorScheme", (value) => {
|
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
// src/support/configure.ts
|
|
71
|
-
import { config } from "@fkui/vue";
|
|
72
71
|
function resetEmulatedMedia(emulatedMedia3) {
|
|
73
72
|
if (!emulatedMedia3.isEnabled()) {
|
|
74
73
|
return;
|
|
@@ -79,7 +78,8 @@ function resetEmulatedMedia(emulatedMedia3) {
|
|
|
79
78
|
log: false
|
|
80
79
|
});
|
|
81
80
|
}
|
|
82
|
-
function configure(options) {
|
|
81
|
+
async function configure(options) {
|
|
82
|
+
const { config } = options.fkuiVue ?? await import("@fkui/vue");
|
|
83
83
|
if (Cypress.testingType === "component") {
|
|
84
84
|
config.teleportTarget = "#teleport";
|
|
85
85
|
}
|
|
@@ -101,34 +101,39 @@ function configure(options) {
|
|
|
101
101
|
|
|
102
102
|
// src/support/mount.ts
|
|
103
103
|
import { mount as originalMount } from "cypress/vue";
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
options.global ??= {};
|
|
114
|
-
options.global.plugins ??= [];
|
|
115
|
-
options.global.config ??= {};
|
|
116
|
-
options.global.config.compilerOptions ??= {};
|
|
117
|
-
options.global.config.compilerOptions.whitespace = "preserve";
|
|
118
|
-
options.global.plugins.push(
|
|
104
|
+
async function createMount(options) {
|
|
105
|
+
const {
|
|
106
|
+
FormatPlugin,
|
|
107
|
+
TestPlugin,
|
|
108
|
+
TranslationPlugin,
|
|
109
|
+
ValidationPlugin,
|
|
110
|
+
setRunningContext
|
|
111
|
+
} = options?.fkuiVue ?? await import("@fkui/vue");
|
|
112
|
+
const plugins = [
|
|
119
113
|
FormatPlugin,
|
|
120
114
|
TestPlugin,
|
|
121
115
|
TranslationPlugin,
|
|
122
116
|
ValidationPlugin
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
117
|
+
];
|
|
118
|
+
return (component, options2) => {
|
|
119
|
+
options2 ??= {};
|
|
120
|
+
options2.global ??= {};
|
|
121
|
+
options2.global.plugins ??= [];
|
|
122
|
+
options2.global.config ??= {};
|
|
123
|
+
options2.global.config.compilerOptions ??= {};
|
|
124
|
+
options2.global.config.compilerOptions.whitespace = "preserve";
|
|
125
|
+
options2.global.plugins.push(...plugins);
|
|
126
|
+
options2.global.plugins.push({
|
|
127
|
+
install(app) {
|
|
128
|
+
setRunningContext(app);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return originalMount(component, options2);
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
var mount = await createMount();
|
|
131
135
|
export {
|
|
132
136
|
configure,
|
|
137
|
+
createMount,
|
|
133
138
|
mount
|
|
134
139
|
};
|
package/dist/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forsakringskassan/cypress-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Sharable Cypress configuration building blocks for Försäkringskassan",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cypress"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@forsakringskassan/cypress-axe": "5.1.5",
|
|
45
45
|
"cypress-html-validate": "9.1.0",
|
|
46
|
-
"mocha-multi-reporters": "1.5.
|
|
46
|
+
"mocha-multi-reporters": "1.5.2"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@fkui/vue": ">= 6.0.0",
|