@forsakringskassan/cypress-config 1.9.2 → 1.10.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
@@ -78,6 +78,10 @@ It adds the following Vue plugins from `@fkui/vue`:
78
78
  - [`TranslationPlugin`](https://designsystem.forsakringskassan.se/latest/functions/plugins/translationplugin.html)
79
79
  - [`ValidationPlugin`](https://designsystem.forsakringskassan.se/latest/functions/plugins/validationplugin.html)
80
80
 
81
+ Additionally, it also:
82
+
83
+ - Treats Vue warnings as errors.
84
+
81
85
  To use, edit `cypress/support/component.ts`:
82
86
 
83
87
  ```diff
package/dist/support.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type * as FkuiVue from '@fkui/vue';
2
2
  import { mount as mount_2 } from 'cypress/vue';
3
+ import { Plugin } from 'vue';
3
4
 
4
5
  /**
5
6
  * Configure plugins.
@@ -39,8 +40,17 @@ export declare function configure(options: {
39
40
  */
40
41
  export declare function createMount(options?: {
41
42
  fkuiVue?: typeof FkuiVue;
43
+ failOnWarning?: boolean;
42
44
  }): Promise<MountFn>;
43
45
 
46
+ /**
47
+ * Fails Cypress test if a Vue warning is encountered.
48
+ *
49
+ * @public
50
+ * @since v1.10.0
51
+ */
52
+ export declare function failOnWarningPlugin(): Plugin;
53
+
44
54
  /**
45
55
  * Wrapper around `mount()` from `cypress/vue` with new defaults.
46
56
  *
package/dist/support.mjs CHANGED
@@ -99,16 +99,32 @@ async function configure(options) {
99
99
  }
100
100
  }
101
101
 
102
+ // src/support/fail-on-warning-plugin.ts
103
+ function failOnWarningPlugin() {
104
+ return {
105
+ install(app) {
106
+ const originalHandler = app.config.warnHandler;
107
+ app.config.warnHandler = (err, vm, info) => {
108
+ if (originalHandler) {
109
+ originalHandler(err, vm, info);
110
+ }
111
+ assert.fail([err, info].join("\n"));
112
+ };
113
+ }
114
+ };
115
+ }
116
+
102
117
  // src/support/mount.ts
103
118
  import { mount as originalMount } from "cypress/vue";
104
119
  async function createMount(options) {
120
+ const { fkuiVue = await import("@fkui/vue"), failOnWarning = true } = options ?? {};
105
121
  const {
106
122
  FormatPlugin,
107
123
  TestPlugin,
108
124
  TranslationPlugin,
109
125
  ValidationPlugin,
110
126
  setRunningContext
111
- } = options?.fkuiVue ?? await import("@fkui/vue");
127
+ } = fkuiVue;
112
128
  const plugins = [
113
129
  FormatPlugin,
114
130
  TestPlugin,
@@ -128,6 +144,9 @@ async function createMount(options) {
128
144
  setRunningContext(app);
129
145
  }
130
146
  });
147
+ if (failOnWarning) {
148
+ options2.global.plugins.push(failOnWarningPlugin());
149
+ }
131
150
  return originalMount(component, options2);
132
151
  };
133
152
  }
@@ -135,5 +154,6 @@ var mount = await createMount();
135
154
  export {
136
155
  configure,
137
156
  createMount,
157
+ failOnWarningPlugin,
138
158
  mount
139
159
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/cypress-config",
3
- "version": "1.9.2",
3
+ "version": "1.10.0",
4
4
  "description": "Sharable Cypress configuration building blocks for Försäkringskassan",
5
5
  "keywords": [
6
6
  "cypress"