Skip to content

Commit 179318b

Browse files
committed
fix(MissingObserver polyfill): add MissingObserver polyfill for jest environment
affects: @patternfly/react-console, patternfly-react Referenced from noVNC (@novnc/nvnc/core/util/events.js). Workaround for the 'jest' testing only since the MutationObserver is available in browsers otherwise. Attempt to fix the issue by using 'browser' jest configuration option did not work in this case.
1 parent 650e9d9 commit 179318b

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"lerna-semantic-release": "^9.1.0",
7373
"lint-staged": "^7.0.4",
7474
"lodash": "^4.17.0",
75+
"mutation-observer": "^1.0.3",
7576
"node-sass": "^4.8.3",
7677
"prettier": "^1.11.1",
7778
"prettier-eslint": "^8.8.1",

test.env.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@ import 'raf/polyfill';
22
import { configure } from 'enzyme';
33
import Adapter from 'enzyme-adapter-react-16';
44

5+
const MutationObserverPolyfill = require('mutation-observer');
6+
7+
// referenced from '@novnc/nvnc/core/util/events.js'
8+
// The MutationObserver is available in supported browsers, this is workaround for "jest"
9+
global.MutationObserver = global.MutationObserver || MutationObserverPolyfill;
10+
511
configure({ adapter: new Adapter() });

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8393,6 +8393,10 @@ [email protected]:
83938393
version "2.1.1"
83948394
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"
83958395

8396+
mutation-observer@^1.0.3:
8397+
version "1.0.3"
8398+
resolved "https://registry.yarnpkg.com/mutation-observer/-/mutation-observer-1.0.3.tgz#42e9222b101bca82e5ba9d5a7acf4a14c0f263d0"
8399+
83968400
83978401
version "0.0.6"
83988402
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.6.tgz#48962b19e169fd1dfc240b3f1e7317627bbc47db"

0 commit comments

Comments
 (0)