@forsakringskassan/cypress-config 1.6.1 → 1.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/README.md CHANGED
@@ -11,7 +11,10 @@ npm install --save-dev @forsakringskassan/cypress-config
11
11
  If you previously had these packages installed, they can be uninstalled:
12
12
 
13
13
  ```bash
14
- npm rm mocha-multi-reporter
14
+ npm rm \
15
+ @forsakringskassan/cypress-axe \
16
+ cypress-html-validate \
17
+ mocha-multi-reporter
15
18
  ```
16
19
 
17
20
  - [Usage](#usage)
@@ -67,6 +70,33 @@ configure({
67
70
  - `resetEmulatedMedia` - When enabled, any emulated CSS media features will be reset between runs.
68
71
  - `afterEach` - Enables features to automatically run after each test. See the various components for details.
69
72
 
73
+ For component tests a preconfigured `mount` function is available.
74
+ It adds the following Vue plugins from `@fkui/vue`:
75
+
76
+ - [`FormatPlugin`](https://designsystem.forsakringskassan.se/latest/functions/plugins/formatplugin.html)
77
+ - [`TestPlugin`](https://designsystem.forsakringskassan.se/latest/functions/plugins/testplugin.html)
78
+ - [`TranslationPlugin`](https://designsystem.forsakringskassan.se/latest/functions/plugins/translationplugin.html)
79
+ - [`ValidationPlugin`](https://designsystem.forsakringskassan.se/latest/functions/plugins/validationplugin.html)
80
+
81
+ To use, edit `cypress/support/component.ts`:
82
+
83
+ ```diff
84
+ -import { mount } from "cypress/mount";
85
+ -import { configure } from "@forsakringskassan/cypress-config/support";
86
+ +import { configure, mount } from "@forsakringskassan/cypress-config/support";
87
+
88
+ Cypress.Commands.add("mount", mount);
89
+ ```
90
+
91
+ If you need further customization, wrap it in your own custom function:
92
+
93
+ ```ts
94
+ Cypress.Commands.add("mount", (component, options = {}) => {
95
+ /* modify options as needed */
96
+ return mount(component, options);
97
+ });
98
+ ```
99
+
70
100
  ### Commands
71
101
 
72
102
  This preset adds new custom commands:
package/dist/support.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import "@forsakringskassan/cypress-axe/support";
2
- import "cypress-html-validate/commands";
3
-
1
+ import { mount as mount_2 } from 'cypress/vue';
2
+
4
3
  /**
5
4
  * Configure plugins.
6
5
  *
@@ -15,9 +14,29 @@ export declare function configure(options: {
15
14
  };
16
15
  }): void;
17
16
 
17
+ /**
18
+ * Wrapper around `mount()` from `cypress/vue` with new defaults.
19
+ *
20
+ * @public
21
+ * @since v1.7.0
22
+ */
23
+ export declare const mount: (component: Parameters<typeof mount_2>[0], options?: NonNullable<Parameters<typeof mount_2>[1]>) => ReturnType<typeof mount_2>;
24
+
18
25
  export { }
19
26
 
20
27
 
28
+ import "@forsakringskassan/cypress-axe/support";
29
+ import { type mount as cypressMount } from "cypress/vue";
30
+ import "cypress-html-validate/commands";
31
+ declare global {
32
+ namespace Cypress {
33
+ interface Chainable {
34
+ mount: typeof cypressMount;
35
+ }
36
+ }
37
+ }
38
+
39
+
21
40
  declare global {
22
41
  namespace Cypress {
23
42
  interface Chainable {
package/dist/support.mjs CHANGED
@@ -94,6 +94,37 @@ function configure(options) {
94
94
  });
95
95
  }
96
96
  }
97
+
98
+ // src/support/mount.ts
99
+ import { mount as originalMount } from "cypress/vue";
100
+ import {
101
+ FormatPlugin,
102
+ TestPlugin,
103
+ TranslationPlugin,
104
+ ValidationPlugin,
105
+ setRunningContext
106
+ } from "@fkui/vue";
107
+ var mount = (component, options) => {
108
+ options ??= {};
109
+ options.global ??= {};
110
+ options.global.plugins ??= [];
111
+ options.global.config ??= {};
112
+ options.global.config.compilerOptions ??= {};
113
+ options.global.config.compilerOptions.whitespace = "preserve";
114
+ options.global.plugins.push(
115
+ FormatPlugin,
116
+ TestPlugin,
117
+ TranslationPlugin,
118
+ ValidationPlugin
119
+ );
120
+ options.global.plugins.push({
121
+ install(app) {
122
+ setRunningContext(app);
123
+ }
124
+ });
125
+ return originalMount(component, options);
126
+ };
97
127
  export {
98
- configure
128
+ configure,
129
+ mount
99
130
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/cypress-config",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "Sharable Cypress configuration building blocks for Försäkringskassan",
5
5
  "keywords": [
6
6
  "cypress"