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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-03 15:09:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-03 15:09:42 +0300
commit6b3944a90167998424f6f258dcffcd4ec740ef03 (patch)
tree52be4c90a768d55655631d1b8058bced792813ce /spec/frontend/environment.js
parent42d930072f05883b7b1b0cc060c175912ea942dc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/environment.js')
-rw-r--r--spec/frontend/environment.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/spec/frontend/environment.js b/spec/frontend/environment.js
index 29aa416149c..cf47a1cd7bb 100644
--- a/spec/frontend/environment.js
+++ b/spec/frontend/environment.js
@@ -88,13 +88,32 @@ class CustomEnvironment extends JSDOMEnvironment {
}),
});
- this.global.PerformanceObserver = class {
+ /**
+ * JSDom doesn't have an own observer implementation, so this a Noop Observer.
+ * If you are testing functionality, related to observers, have a look at __helpers__/mock_dom_observer.js
+ *
+ * JSDom actually implements a _proper_ MutationObserver, so no need to mock it!
+ */
+ class NoopObserver {
/* eslint-disable no-useless-constructor, no-unused-vars, no-empty-function, class-methods-use-this */
constructor(callback) {}
disconnect() {}
observe(element, initObject) {}
+ unobserve(element) {}
+ takeRecords() {
+ return [];
+ }
/* eslint-enable no-useless-constructor, no-unused-vars, no-empty-function, class-methods-use-this */
- };
+ }
+
+ ['IntersectionObserver', 'PerformanceObserver', 'ResizeObserver'].forEach((observer) => {
+ if (this.global[observer]) {
+ throw new Error(
+ `We overwrite an existing Observer in jsdom (${observer}), are you sure you want to do that?`,
+ );
+ }
+ this.global[observer] = NoopObserver;
+ });
}
async teardown() {