Skip to content

Commit

Permalink
fix(MissingObserver polyfill): add MissingObserver polyfill for jest …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
mareklibra committed Jun 26, 2018
1 parent 4199927 commit 6e0d6f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"lerna-semantic-release": "^9.1.0",
"lint-staged": "^7.0.4",
"lodash": "^4.17.0",
"mutation-observer": "^1.0.3",
"node-sass": "^4.8.3",
"npmlog": "^4.1.2",
"prettier": "^1.11.1",
Expand Down
6 changes: 6 additions & 0 deletions test.env.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ import Adapter from 'enzyme-adapter-react-16';
import { preventInjection } from './packages/react-styles';

preventInjection();

const MutationObserverPolyfill = require('mutation-observer');
// referenced from '@novnc/nvnc/core/util/events.js'
// The MutationObserver is available in supported browsers, this is workaround for "jest"
global.MutationObserver = global.MutationObserver || MutationObserverPolyfill;

configure({ adapter: new Adapter() });
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9772,6 +9772,10 @@ ms@2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"

mutation-observer@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/mutation-observer/-/mutation-observer-1.0.3.tgz#42e9222b101bca82e5ba9d5a7acf4a14c0f263d0"

mute-stream@0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.6.tgz#48962b19e169fd1dfc240b3f1e7317627bbc47db"
Expand Down

0 comments on commit 6e0d6f0

Please sign in to comment.