Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/__helpers__/set_vue_error_handler.js')
-rw-r--r--spec/frontend/__helpers__/set_vue_error_handler.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/frontend/__helpers__/set_vue_error_handler.js b/spec/frontend/__helpers__/set_vue_error_handler.js
new file mode 100644
index 00000000000..d254630d1e4
--- /dev/null
+++ b/spec/frontend/__helpers__/set_vue_error_handler.js
@@ -0,0 +1,30 @@
+import Vue from 'vue';
+
+const modifiedInstances = [];
+
+export function setVueErrorHandler({ instance, handler }) {
+ if (Vue.version.startsWith('2')) {
+ // only global handlers are supported
+ const { config } = Vue;
+ config.errorHandler = handler;
+ return;
+ }
+
+ // eslint-disable-next-line no-param-reassign
+ instance.$.appContext.config.errorHandler = handler;
+ modifiedInstances.push(instance);
+}
+
+export function resetVueErrorHandler() {
+ if (Vue.version.startsWith('2')) {
+ const { config } = Vue;
+ config.errorHandler = null;
+ return;
+ }
+
+ modifiedInstances.forEach((instance) => {
+ // eslint-disable-next-line no-param-reassign
+ instance.$.appContext.config.errorHandler = null;
+ });
+ modifiedInstances.length = 0;
+}