Skip to content

Commit fe804bf

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 0caf5ea commit fe804bf

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
@@ -78,6 +78,7 @@
7878
"lerna-semantic-release": "^9.1.0",
7979
"lint-staged": "^7.0.4",
8080
"lodash": "^4.17.0",
81+
"mutation-observer": "^1.0.3",
8182
"node-sass": "^4.8.3",
8283
"npmlog": "^4.1.2",
8384
"prettier": "^1.11.1",

test.env.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@ import Adapter from 'enzyme-adapter-react-16';
44
import { preventInjection } from './packages/react-styles';
55

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

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9772,6 +9772,10 @@ ms@2.1.1:
97729772
version "2.1.1"
97739773
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"
97749774

9775+
mutation-observer@^1.0.3:
9776+
version "1.0.3"
9777+
resolved "https://registry.yarnpkg.com/mutation-observer/-/mutation-observer-1.0.3.tgz#42e9222b101bca82e5ba9d5a7acf4a14c0f263d0"
9778+
97759779
mute-stream@0.0.6:
97769780
version "0.0.6"
97779781
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.6.tgz#48962b19e169fd1dfc240b3f1e7317627bbc47db"

0 commit comments

Comments
 (0)